This article mainly introduces the PHP process control of the continue statement, has a certain reference value, now share to everyone, the need for friends can refer to
This paper tries to use the basic Learning Master, please close this page
This article read 15 minutes, understand difficult to say, encourage yourself to experiment
(PHP 4, PHP 5, PHP 7)
Continue is used in the loop structure to skip the remaining code in this loop and start the next loop when the condition evaluates to True.
Note: Notice that the switch statement in PHP is considered a looping structure that can use continue.
Continue accepts an optional numeric parameter to decide to skip a few loops to the end of the loop. The default value is 1, which jumps to the end of the current loop.
<?phpwhile (List ($key, $value) = each ($arr)) { if (!) ( $key% 2)) {//Skip odd members continue; } Do_something_odd ($value);} $i = 0;while ($i + < 5) { echo "outer<br/>\n"; while (1) { echo "middle<br/>\n"; while (1) { echo "inner<br/>\n"; Continue 3; } echo "This never gets output.<br/>\n"; } echo "Neither does this.<br/>\n";}? >
Omitting the semicolon after continue causes confusion. The following examples indicate that this should not be done.
<?php for ($i = 0; $i < 5; + + $i) { if ($i = = 2) continue print "$i \ n"; }? >
The desired result is:
0134
The actual output can be:
2