Results 1 to 4 of 4

Thread: array problems.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    168

    array problems.

    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
    Attached Files Attached Files
    • File Type: rar 1.rar (336 Bytes, 29 views)
    Last edited by gate7cy; Sep 16th, 2009 at 06:40 PM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: array problems.

    copy and paste the PHP file's code here. no need for a rar file. be sure to enclose it in [php] and [/php] tags, too.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    168

    Re: array problems.

    here it is
    PHP Code:
    <?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($resultsarray_merge(array($element), $combination));

        return 
    $results;
    }

    $power_set test($set);

    foreach (
    test($set) as $combination) {
        if (
    $no == count($combination)) {
            print 
    join(" , "$combination) . "<br>";
        }
    }

    ?>

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    168

    Re: array problems.

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width