continueは、ループ構造において現在の繰り返しループ の残りの処理をスキップし、次の繰り返しの最初から実行を続けるために 使用されます、
continueでは、オプションの引数で 処理をスキップするループ構造のレベルの数を指定できます。
while (list ($key,$value) = each ($arr)) {
if (!($key % 2)) { // キーが偶数の組をスキップ
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";
} |