Here's the function I use:
// array array_permute(array [, string])
//
// Returns an array containing the permutations of the values in an array.
//
// Example:
// $a = array(1, 2, 3);
// $p = array_permute($a)
//
// Result:
// p[0] = '1,2,3'
// p[1] = '1,3,2'
// p[2] = '2,1,3'
// p[3] = '2,3,1'
recursive function, passing back in the array, minus the current position
and current combination. when array is empty, use current combination.
um... something like (but not tested)
function comby($arr, $comb = "")
{
$num = count($arr);
if ($num == 0)
{
echo $comb;
return;
}
2 matches
Mail list logo