Jump to content

[SOLVED] Alternatives to do() function


shamuraq

Recommended Posts

Hi there,

I try to control the output of this code:

$multiplier = rand(2,7);

//Get value of second volume via $multiplier
//Making sure value of second volume is not greater than 10,000 to control array only up to 4

do {
$lml_2 = $lml_1 * $multiplier;
} while ($lml_2 > 10000);

and i get this error:

Fatal error: Maximum execution time of 30 seconds exceeded in volume02.php on line 26

Is there any alternative to the do() while() function?

Link to comment
https://forums.phpfreaks.com/topic/170675-solved-alternatives-to-do-function/
Share on other sites

Well what's the value of $lml_1? The condition to execute your loop is dependent on $lml_2 = $lml_1 * $multiplier being less than 10000; but if it isn't, the loop will never exit at all and you will eventually time out.

 

Why are you even using a do while loop here?

 

Its because $lml_1 is produced with rand();

So for 100% exceeding 10,000 is impossible. Sadly, so is vice versa. I have other options but since i am in my transitional state of understanding PHP, i just wanna learn my options.

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.