| Posted by Alkimake on 03/29/06 15: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;
 }
 
 
 By the way this code is perfect. i have never seen a solution like
 this. Thank you very much Oli. And second thank is for making me think.
 Actually i didn't want somebody to answer me completely because to
 understand the algoritm is more more more important than copy & paste
 for me. This is impressive.
 
 Actually i did the combinations when i saw your message but it is about
 120 lines :) and very slow.
 
 Take care and see ya.
 
 PS: if i had mistakes i am sorry cuz my english is not so good :)
  Navigation: [Reply to this message] |