continue statement with a level to skip a part inside a sessioncontinue statement with a level to skip an entire sessioncontinue statement with a level to skip a part inside a sessioncontinue statement with a level to skip an entire sessionfor loop with variable $session from 1 to 3 and inside it create another for loop with variable $part from 1 to 4.Use two for loops, one inside the other, with the exact variable names $session and $part.
if statement inside the inner loop to check if $session is 2 and $part is 3. Use continue 1; to skip only this part.Use continue 1; to skip only the current iteration of the inner loop.
if statement inside the inner loop to check if $session is 3. Use continue 2; to skip the entire session including all its parts.Use continue 2; to skip the current iteration of the outer loop from inside the inner loop.
continue statements, add a print statement to display "Session $session - Part $part\n".Use print("Session $session - Part $part\n"); to show the current session and part.
What does the continue statement do inside a loop in PHP?
continue in loopscontinue statement tells the loop to skip the remaining code in the current iteration.continue?continue skips current iteration [OK]Which of the following is the correct syntax to skip the current iteration of the outer loop in nested loops using continue in PHP?
for ($i = 0; $i < 3; $i++) {
for ($j = 0; $j < 3; $j++) {
if ($j == 1) {
// What continue statement skips outer loop iteration?
}
}
}continue 2;.continue n; syntaxcontinue 2; skips the current iteration of the second enclosing loop (outer loop).continue 2; skips outer loop iteration [OK]What will be the output of the following PHP code?
for ($i = 1; $i <= 3; $i++) {
for ($j = 1; $j <= 3; $j++) {
if ($j == 2) {
continue 2;
}
echo "$i$j ";
}
}continue 2; skips the rest of the inner and outer loop iteration, moving to next $i.Find the error in this PHP code snippet that tries to skip the outer loop iteration when $j == 2:
for ($i = 0; $i < 3; $i++) {
for ($j = 0; $j < 3; $j++) {
if ($j == 2) {
continue 3;
}
echo "$i$j ";
}
}continue 3; tries to skip 3 levels, but only 2 exist, causing a fatal error.You want to print all pairs (i, j) for i and j from 1 to 3, but skip printing pairs where j == 2 and also skip the entire outer loop iteration if i == 2. Which code snippet correctly uses continue with levels to achieve this?
for ($i = 1; $i <= 3; $i++) {
if ($i == 2) continue;
for ($j = 1; $j <= 3; $j++) {
if ($j == 2) continue;
echo "($i,$j) ";
}
} skips i == 2 outer loop correctly but skips j == 2 only in inner loop.for ($i = 1; $i <= 3; $i++) {
for ($j = 1; $j <= 3; $j++) {
if ($j == 2) continue;
if ($i == 2) continue 2;
echo "($i,$j) ";
}
} tries to continue 2 inside inner loop after j check, but order is wrong.for ($i = 1; $i <= 3; $i++) {
for ($j = 1; $j <= 3; $j++) {
if ($i == 2) continue 2;
if ($j == 2) continue;
echo "($i,$j) ";
}
} first skips outer loop iteration if i == 2 using continue 2;, then skips j == 2 in inner loop.for ($i = 1; $i <= 3; $i++) {
for ($j = 1; $j <= 3; $j++) {
if ($i == 2 || $j == 2) continue 2;
echo "($i,$j) ";
}
} skips outer loop iteration if either i == 2 or j == 2, which is incorrect.Pass the test and this pattern moves unknown