while ($i > 10) { if ($j = 5) { //What code can I put here to go straight to the next value of $i in the current while loop? } //rest of while loop }
break;
No.
break stop the while() loop.
Use "continue" to skip the rest of the loop and go straight to the next value of the while() loop.
A forum, a FAQ, email notification, what else do you need?
My bad 🙂
You naughty boy you! 🙂
<?php $i = 0; while ($i <= 10) { if ($i == 5) { continue; } print $i; $i++; } ?>
Would that be correct? I ask because it gives me a "Maximum execution time of 30 seconds exceeded" message whenever I run that code.
Thanks
The loop is infinite because $i stays 5 forever.
This works:
<?php $i = 0; while ($i <= 10) { if ($i == 5) { $i++; continue; } print $i; $i++; } ?>