- array_shift: documentation ( source)
<?php
function permutation(array $arr)
{
while($ele=array_shift($arr))
{
$x=$ele;
echo $x."\n";
foreach($arr as $rest)
{
$x.=" $rest";
echo $x."\n";
}
}
}
permutation(array(array('red', 'blue', 'green'),array('small', 'med', 'large'),array('car', 'truck', 'van')));