Jump to content

[SOLVED] How to put an IF statement in the for loop and keep it runnig.


pocobueno1388

Recommended Posts

I am trying to put an IF statement in a for loop and if that if statement is false it won't execute the rest of the code in the for loop below it but still continue on to the next for value...

 

Let me give you an example of what I am doing and it isn't working.

 

<?php

for ($i=0; $i<10; $i++){
   
   if ($i == 5){
   break;
   }
   
echo "$i<br>";

}

/*
prints:

0
1
2
3
4
...then stops
*/
?>

 

If $i equaled 5 how would I not execute the code below that IF statement yet let $i move on to 6..7...8..etc?

 

What I have is an auction script, and if the item has no bids on it when the auction is over or doesn't meet the reserve, I want it to put the item back into the persons inventory, but if the item did sell and meet the requirements I want to go on and exectuted the codes that transfer the item/money.

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.