PHP - Loops
You want to stop processing nested loops early when a condition is met, but only exit the inner loop sometimes and both loops other times. Which code snippet correctly uses break with levels?
for ($i = 0; $i < 5; $i++) {
for ($j = 0; $j < 5; $j++) {
if ($i == 2 && $j == 3) {
break 2; // exit both loops
} elseif ($j == 4) {
break; // exit inner loop only
}
echo "$i,$j\n";
}
}