- print_r: documentation ( source)
- array_shift: documentation ( source)
<?php
print_r(ordered_combinations(Array("one", "two", "three", "four")));
function ordered_combinations($array){
if(is_array($array)){
while(count($array) > 0){
foreach($array as $element){
$string = $string . " " . $element;
$output[] = $string;
}
$string = "";
array_shift($array);
}
return $output;
}
}