I want to get all possible phrases (which actually exist) in a sentence as
$str = 'word1 word2 word3 word4';
$output = array ('word1 word2 word3', 'word1 word2',
'word2 word3 word4', 'word3 word4', 'word2 word3');
To do so, I create an array of words as,
$words = explode(' ', $str);
There are several questions here explaining how to build all combinations of the elements of an array, but how can I make all the combinations while preserving the original order?
How can I make the array of $output
out of $words
?