1

i am badly struck in this error... simply unable to get it

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\vas1\apriori.php on line 36

my code for this function was like:

function combination($member,$num){
  $n = count($member);  

  $total = pow(2, $n); 
  $list =array();

  $k=0;
  for ($i = 0; $i < $total; $i++) {   
    $list[$k]=array();

    for ($j = 0; $j < $total; $j++) {  

        if ((pow(2, $j) & $i)) $list[$k][]=$member[$j];       
    }
    if(count($list[$k])==$num){

      $k++;
    }else{

      unset($list[$k]);
    }
  }
  return $list;
}

and line 36 is:

 if ((pow(2, $j) & $i)) $list[$k][]=$member[$j];  
mary
  • 32
  • 6
  • I don't mean to be rude or anything, but what did say the numerous similar posts about this exact subject? – Sebas Jun 18 '13 at 19:01
  • your code really looks hard and may work for a long time. You may use set_time_limit(0) function to disable 30 seconds execution time limit. – Karim Jun 18 '13 at 19:06
  • what are $member and $num values you are calling the function on? – geryjuhasz Jun 18 '13 at 19:06
  • you're exceeding the max allowed runtime, exactly as the error message says. The fact that it happened on 36 is purely coincidental. You can run out of allowed runtime **ANYWHERE** in that script, and your code is "fine". It's just taking longer to run than allowed. – Marc B Jun 18 '13 at 19:22

1 Answers1

1

as people have pointed out you have exceeded the maximum allowed script runtime which is by default 30 seconds.

To change this, add to the beginning of your script:

ini_set('max_execution_time', 300);//for 300 seconds
Aris
  • 4,643
  • 1
  • 41
  • 38