3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('hachi', 'dora', 'tiger', 'iris', 'gokito', 'chorizoornitorrinco1991'); function depth_picker($arr, $temp_string, &$collect) { if ($temp_string != "") $collect []= $temp_string; for ($i=0; $i<sizeof($arr);$i++) { $arrcopy = $arr; $elem = array_splice($arrcopy, $i, 1); // removes and returns the i'th element if (sizeof($arrcopy) > 0) { depth_picker($arrcopy, $temp_string ."" . $elem[0], $collect); } else { $collect []= $temp_string. "" . $elem[0]; } } } $collect = array(); depth_picker($array, "", $collect); print_r(json_encode($collect));

preferences:
54.26 ms | 402 KiB | 5 Q