3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } }

preferences:
56.14 ms | 402 KiB | 5 Q