continue
continue
is used within looping structures to
skip the rest of the current loop iteration and continue execution
at the condition evaluation and then the beginning of the next iteration.
continue
Opmerking: > In PHP the statement is considered a looping structure for the purposes of . behaves like (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a is inside a loop, will continue with the next iteration of the outer loop. switch
continue``continue``break``switch``continue 2
accepts an optional numeric argument
which tells it how many levels of enclosing loops it should skip
to the end of. The default value is , thus skipping
to the end of the current loop.
continue``1
<?php
$arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
foreach ($arr as $key => $value) {
if (0 === ($key % 2)) { // skip members with even key
continue;
}
echo $value . "\n";
}
?>
one
three
five
<?php
$i = 0;
while ($i++ < 5) {
echo "Outer\n";
while (1) {
echo "Middle\n";
while (1) {
echo "Inner\n";
continue 3;
}
echo "This never gets output.\n";
}
echo "Neither does this.\n";
}
?>
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Omitting the semicolon after can lead to
confusion. Here's an example of what you shouldn't do.
continue
<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i\n";
}
?>
One can expect the result to be:
0
1
3
4