Bird
0
0

What does the continue 2; statement do inside nested loops in PHP?

easy📝 Conceptual Q1 of 15
PHP - Loops

What does the continue 2; statement do inside nested loops in PHP?

AExits both loops immediately
BSkips the rest of the current iteration of the inner loop and continues with the next iteration of the outer loop
CSkips only the current iteration of the inner loop
DRestarts the entire script from the beginning
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of continue with a number

    The number after continue tells PHP how many nested loops to skip to the next iteration.
  2. Step 2: Apply continue 2 in nested loops

    continue 2 skips the current iteration of the inner loop and also skips to the next iteration of the outer loop.
  3. Final Answer:

    Skips the rest of the current iteration of the inner loop and continues with the next iteration of the outer loop -> Option B
  4. Quick Check:

    continue 2 = skip inner and outer loop iteration [OK]
Quick Trick: continue n skips n nested loops' current iterations [OK]
Common Mistakes:
  • Thinking continue 2 exits both loops
  • Confusing continue with break
  • Assuming continue 2 only affects inner loop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes