I want to implode all sequential elements of an array.
$array = array('First', 'Second', 'Third', 'Fourth');
The output should be
First
Second
Third
Fourth
First Second
Second Third
Third Fourth
First Second Third
Second Third Fourth
First Second Third Fourth
I started with an idea of using array_slice,
$l = count($array);
for($i=0;$i<$l;$i++){
echo implode(' ',array_slice($array,$i,$l-$i)).PHP_EOL;
}
but I realised it is a bad idea, as I will need another loop.
What is the fast and neat way to do so?
n-gram.