continue 在循環結構用用來跳過本次循環中剩餘的代碼並開始執行下一次循環。
continue 接受一個可選的數字參數來決定跳過幾重循環到循環結尾。
while (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";
} |