- var_dump: documentation ( source)
- array_shift: documentation ( source)
<?php
function permutation(array $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"));