Jump to content

Fatal error: Maximum execution time of 30 seconds exceeded


jlryan87

Recommended Posts

Hello everyone. Today I make a code to display numbers 1-20 randomly without repeating any of the numbers. The result is fine but I keep on getting Fatal error: Maximum execution time of 30 seconds exceeded. Personally I don't think PHP will have much trouble going through the loop. Here's the code I have written:

<?

 

$i = 0;

$m = 20;

 

while ($i<$m){

$n = rand(1,20);

if (ereg(" ".$n." ", $k) == 1){

$i -=1;

}else{

$k .= " ".$n." ";

echo " $n ";

$i +=1;

}

}

 

?>

 

Is there any way I can write the code without having the fatal error?

What is wrong with my code? There's no infinite loop and I don't think there is a long loop either.

 

Thanks everyone who gives some help.

  • 2 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.