Advertisement

Google Ad Slot: content-top

PHP Continue


When executed, continue skips the rest of the code inside the current iteration of the loop and jumps to the next iteration.


Using continue in a for Loop


The continue statement stops the current iteration in the for loop and continue with the next.

Example
<?php
for ($i = 0; $i < 10; $i++) {
if ($i % 2 == 0) {
continue; // Skip the rest of the loop for even numbers
}
echo "Odd number: $i\n";
}
?>
Try it yourself

Note

You can also use continue statement in while, do...while and foreach loop.