continuePHP ManualPrevChapter 11. Control StructuresNextcontinue
continue is used within looping structures to
skip the rest of the current loop iteration and continue execution
at the beginning of the next iteration.
continue accepts an optional numeric argument
which tells it how many levels of enclosing loops it should skip
to the end of.
1
2 while (list ($key, $value) = each ($arr)) {
3 if (!($key % 2)) { // skip odd members
4 continue;
5 }
6 do_something_odd ($value);
7 }
8
9 $i = 0;
10 while ($i++ < 5) {
11 echo "Outer<br>\n";
12 while (1) {
13 echo " Middle<br>\n";
14 while (1) {
15 echo " Inner<br>\n";
16 continue 3;
17 }
18 echo "This never gets output.<br>\n";
19 }
20 echo "Neither does this.<br>\n";
21 }
22
PrevHomeNextbreakUpswitch