不知道如何解释.我们来举个例子吧.说我想分开这句话
“今天是个好日子.”
成
today today is today is a today is a great today is a great day is is a is a great is a great day a a great a great day great great day day
这个想法是在一个句子中得到所有顺序组合.
这是一个例子:
原文链接:https://www.f2er.com/php/130420.html$sentence = 'Today is a great day.'; // Only leave "word" characters and whitespace $sentence = preg_replace('/[^\w\s]+/','',strtolower($sentence)); // Tokenize $tokens = explode(' ',$sentence); for($i = 0; $i < count($tokens); $i++) { for($j = 1; $j <= count($tokens) - $i; $j++) { echo implode(' ',array_slice($tokens,$i,$j)) . "<br />"; } }
输出:
today today is today is a today is a great today is a great day is is a is a great is a great day a a great a great day great great day day