3v4l.org

run code in 300+ PHP versions simultaneously
<?php function permutation(array $arr) { $out = array(); while($ele=array_shift($arr)) { $x=$ele; //echo $x."\n"; foreach($arr as $rest) { $x.=" $rest"; //echo $x."\n"; array_push($out, $x); } } foreach($out as $o) { echo $o; } } permutation(array("Rafting","Hiking","Running","Biking"));

preferences:
42.05 ms | 402 KiB | 5 Q