Jump to content

[SOLVED] for statements


MemphiS

Recommended Posts

i have two values i wish to use in the one for(); Ill make an example below which will make it easier to understand what im trying to do.

 

<?php
$value1 = 100;
$value2 = 100;

for ($i=0;$i<???;$i++){
$value1 = $value1 - rand(0,10);
$value2 = $value2 - rand(0,10);
echo("Value1 is now $value1, And Value2 is now $value2");
if ($value1 < 0){ ???=1; }
if ($value2 < 0){ ???=1; }
}

The question marks (???) is the section that im not sure how to do... As i have two values that are 100 but $value1 or $value2 will reach 0 first and i wish it to stop once either have become 0.

 

Thanks for your responces :)

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.