php continue in switch code example
Example 1: php continue
<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i\n";
}
?>
Example 2: foreach skip current iteration
// You can skip the current iteration using "continue"
// Example: Skip the current iteration if $number is 3;
$numbers = [1, 2, 3, 4, 5];
foreach($numbers as $number) {
if($number == 3) {
continue;
}
echo $number . " + ";
}
// output: 1 + 2 + 4 + 5 +