gate7cy
Sep 16th, 2009, 05:19 PM
i have a small application that gets me all possible combinations of 5 numbers from an array that holds 12 numbers. when i try to alter it and make the elements in the array more and try to get combinations of 7, 6 numbers it says :
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 35 bytes)
I have attached the php file. thanks for the replies
kows
Sep 16th, 2009, 10:23 PM
copy and paste the PHP file's code here. no need for a rar file. be sure to enclose it in and tags, too.
gate7cy
Sep 17th, 2009, 07:38 AM
here it is
<?php
$set = array('1', '2', '3', '4','5', '6', '7', '8', '9', '10', '11', '12', '13','14','15','16','33','53','','223','14', '21', '42', '24','53', '26', '37', '674', '349', '430');
$no = 6;
function test($array) {
$results = array(array( ));
foreach ($array as $element)
foreach ($results as $combination)
array_push($results, array_merge(array($element), $combination));
return $results;
}
$power_set = test($set);
foreach (test($set) as $combination) {
if ($no == count($combination)) {
print join(" , ", $combination) . "<br>";
}
}
?>
gate7cy
Sep 21st, 2009, 09:09 AM
Anyone can help on this???? I got this code from php cookbook. For up to 12 variables choosing 5 number combinatios it works. If I increase the elements and/ or the number combinations it throws this memory error on the line with the function : array_merge. I have tried to increase the memory and increased it as far as 128 mb with not luck. Anyone. Someone.. Thanks