3v4l.org

run code in 300+ PHP versions simultaneously
<?php function permutation($arr) { while($ele=array_shift($arr)) { $row=array($ele); foreach($arr as $rest) { $row[]=$rest; } if(count($row)==2) var_dump($row); } } permutation(array("1","2","3","4"));

preferences:
34.94 ms | 402 KiB | 5 Q