PHP 继续
The continue
statement can be used to jump out of the current iteration of a loop, and continue with the next.
在 For 循环中继续
The continue
statement stops the current iteration in the for
loop and continue with the next.
例子
如果 $x
= 4,则转到下一迭代
for ($x = 0; $x < 10; $x++) {
if ($x == 4) {
continue;
}
echo "The number is: $x <br>";
}
尝试一下 »
在 While 循环中继续
The continue
statement stops the current iteration in the while
loop and continue with the next.
继续示例
如果 $x
= 4,则转到下一迭代
$x = 0;
while($x < 10) {
if ($x == 4) {
continue;
}
echo "The number is: $x <br>";
$x++;
}
尝试一下 »
在 Do While 循环中继续
The continue
statement stops the current iteration in the do...while
loop and continue with the next.
在 For Each 循环中继续
The continue
statement stops the current iteration in the foreach
loop and continue with the next.
例子
停止,如果 $x
为“蓝色”,则跳到下一迭代
$colors = array("red", "green", "blue", "yellow");
foreach ($colors as $x) {
if ($x == "blue") continue;
echo "$x <br>";
}
尝试一下 »