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
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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.