0
0
PHPprogramming~10 mins

Continue statement with levels in PHP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to skip the current iteration in the inner loop.

PHP
<?php
for ($i = 1; $i <= 3; $i++) {
    for ($j = 1; $j <= 3; $j++) {
        if ($j == 2) {
            [1];
        }
        echo "$i,$j\n";
    }
}
?>
Drag options to blanks, or click blank then click option'
Areturn
Bbreak
Cexit
Dcontinue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break' instead of 'continue' which exits the loop instead of skipping iteration.
2fill in blank
medium

Complete the code to skip the current iteration of the outer loop using continue with level.

PHP
<?php
for ($i = 1; $i <= 3; $i++) {
    for ($j = 1; $j <= 3; $j++) {
        if ($j == 2) {
            [1] 2;
        }
        echo "$i,$j\n";
    }
}
?>
Drag options to blanks, or click blank then click option'
Areturn
Bbreak
Ccontinue
Dexit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break 2;' which exits the outer loop instead of continuing it.
3fill in blank
hard

Fix the error in the continue statement to skip the outer loop iteration.

PHP
<?php
for ($x = 1; $x <= 3; $x++) {
    for ($y = 1; $y <= 3; $y++) {
        if ($y == 3) {
            [1] 2;
        }
        echo "$x,$y\n";
    }
}
?>
Drag options to blanks, or click blank then click option'
Acontinue
Bcontinue;
Ccontinue 3
Dcontinue 1
Attempts:
3 left
💡 Hint
Common Mistakes
Including the semicolon inside the blank causing syntax error.
Using wrong level number.
4fill in blank
hard

Fill both blanks to skip the current iteration of the inner loop and continue the outer loop.

PHP
<?php
for ($a = 1; $a <= 3; $a++) {
    for ($b = 1; $b <= 3; $b++) {
        if ($b == 2) {
            [1];
            [2] 2;
        }
        echo "$a,$b\n";
    }
}
?>
Drag options to blanks, or click blank then click option'
Acontinue
Bbreak
Cexit
Dreturn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break' instead of 'continue' which changes loop behavior.
Mixing 'break' and 'continue' incorrectly.
5fill in blank
hard

Fill all three blanks to skip the current iteration of the innermost loop, then the middle loop, then the outer loop.

PHP
<?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";
        }
    }
}
?>
Drag options to blanks, or click blank then click option'
Acontinue
Bbreak
Cexit
Dreturn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break' or 'exit' which exit loops instead of continuing.
Omitting the level number for multi-level continue.