Bird
0
0

Why does continue 2; inside nested loops skip the current iteration of the outer loop instead of just the inner loop?

hard📝 Conceptual Q10 of 15
PHP - Loops

Why does continue 2; inside nested loops skip the current iteration of the outer loop instead of just the inner loop?

ABecause the number after continue specifies how many nested loops to skip
BBecause continue always skips the outer loop by default
CBecause continue 2 is equivalent to break
DBecause PHP ignores the number after continue
Step-by-Step Solution
Solution:
  1. Step 1: Understand continue with levels behavior

    The number after continue tells PHP how many nested loops to skip to the next iteration.
  2. Step 2: Explain why continue 2 skips outer loop

    continue 2 skips the current iteration of the inner loop and the next outer loop iteration, effectively skipping the outer loop iteration.
  3. Final Answer:

    Because the number after continue specifies how many nested loops to skip -> Option A
  4. Quick Check:

    continue n skips n nested loops [OK]
Quick Trick: Number after continue controls how many loops to skip [OK]
Common Mistakes:
  • Thinking continue always skips inner loop only
  • Confusing continue with break
  • Assuming PHP ignores the number after continue

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes