Reputation: 195
I´d like to jump out of a parent switch-statement. Example:
switch(xyz){
case "xyz":
switch(xyz){
case "hello":
// JUMP OUT OF THIS TWO SWITCH-STATEMENTS
break;
}
break;
}
Is there a simple way to realize this?
Upvotes: 2
Views: 395
Reputation: 2621
What you need is the break 2;
break
is nothing else than break 1
- so in your case quitting the second switch.
break 2
will quit the second switch AND the first switch.
switch(xyz){
case "xyz":
switch(xyz){
case "hello":
// JUMP OUT OF THIS TWO SWITCH-STATEMENTS
break 2;
}
break;
}
Upvotes: 1
Reputation: 57002
if you want to break out of the 2 switch statement you can use the optional argument to break
switch(xyz){
case "xyz":
switch(xyz){
case "hello":
// JUMP OUT OF THIS TWO SWITCH-STATEMENTS
break 2;
}
break;
}
check the second example in http://www.php.net/manual/en/control-structures.break.php
Upvotes: 2