Posted by Oli Filth on 03/29/06 16:11
Alkimake said the following on 29/03/2006 13:28:
> Here is the answer that Oli found :)
>
> function getCombinations($values)
> {
> $perms = array(null);
> foreach ($values as $key => $v)
> {
> $temp = $values;
> for ($i=0; $i<=$key; $i++) {
> unset($temp[$i]);
> }
> $newPerms = getCombinations($temp);
> foreach ($newPerms as $perm)
> {
> $perms[] = ($v . $perm);
> }
> }
> return $perms;
> }
>
P.S.: array_splice()
--
Oli
Navigation:
[Reply to this message]
|