94 of 110 menu

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
English
БеларускаяEspañolРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline