I have several loops and would like to specify a particular loop when I use the break or continue instruction
In the PHP doc, it is written that I can use the number numeric argument which tells it how many nested enclosing structures are to be broken out of.
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />\n";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
But I'd like something more friendly like this:
$i = 0;
loop1: // Label/tag of loop1
while (++$i) {
loop2: // Label/tag of loop2
switch ($i) {
case 5:
echo "At 5<br />\n";
break loop2; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />\n";
break loop1; /* Exit the switch and the while. */
default:
break;
}
}
Is it possible?