pocobueno1388 Posted March 13, 2007 Share Posted March 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/42546-solved-how-to-put-an-if-statement-in-the-for-loop-and-keep-it-runnig/ Share on other sites More sharing options...
Orio Posted March 13, 2007 Share Posted March 13, 2007 Use continue. Orio. Link to comment https://forums.phpfreaks.com/topic/42546-solved-how-to-put-an-if-statement-in-the-for-loop-and-keep-it-runnig/#findComment-206433 Share on other sites More sharing options...
pocobueno1388 Posted March 13, 2007 Author Share Posted March 13, 2007 Thanks Orio, thats what I was looking for xP Link to comment https://forums.phpfreaks.com/topic/42546-solved-how-to-put-an-if-statement-in-the-for-loop-and-keep-it-runnig/#findComment-206437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.