PHP Skip Loop Iteration
To skip a loop iteration, you should
use the continue statement.
Let's use a loop to display numbers from
1 to 7, but if
the number is 5 - we will skip
the current loop iteration:
<?php
for ($i = 1; $i <= 7; $i++) {
if ($i == 5) {
continue; // skip iteration
}
echo $i;
}
?>
Code execution result:
1
2
3
4
6
7