Complete the code to skip the current iteration in the inner loop.
<?php for ($i = 1; $i <= 3; $i++) { for ($j = 1; $j <= 3; $j++) { if ($j == 2) { [1]; } echo "$i,$j\n"; } } ?>
The continue statement skips the current iteration of the loop it is in. Here, it skips when $j == 2 in the inner loop.
Complete the code to skip the current iteration of the outer loop using continue with level.
<?php for ($i = 1; $i <= 3; $i++) { for ($j = 1; $j <= 3; $j++) { if ($j == 2) { [1] 2; } echo "$i,$j\n"; } } ?>
The continue 2; statement skips the current iteration of the outer loop (two levels up).
Fix the error in the continue statement to skip the outer loop iteration.
<?php for ($x = 1; $x <= 3; $x++) { for ($y = 1; $y <= 3; $y++) { if ($y == 3) { [1] 2; } echo "$x,$y\n"; } } ?>
The correct syntax is continue 2; without a semicolon inside the blank. The blank replaces only the keyword and level number together, so the blank must be 'continue'. The number 2 is already in the code after the blank.
Fill both blanks to skip the current iteration of the inner loop and continue the outer loop.
<?php for ($a = 1; $a <= 3; $a++) { for ($b = 1; $b <= 3; $b++) { if ($b == 2) { [1]; [2] 2; } echo "$a,$b\n"; } } ?>
First continue; skips the inner loop iteration. Then continue 2; skips the outer loop iteration. Both use 'continue' with and without level.
Fill all three blanks to skip the current iteration of the innermost loop, then the middle loop, then the outer loop.
<?php for ($i = 1; $i <= 3; $i++) { for ($j = 1; $j <= 3; $j++) { for ($k = 1; $k <= 3; $k++) { if ($k == 2) { [1]; [2] 2; [3] 3; } echo "$i,$j,$k\n"; } } } ?>
Each blank uses 'continue' to skip the current iteration at different loop levels: innermost (no level), middle (level 2), and outermost (level 3).