I have something like this
switch($m){
case 1:
some code
break;
case 2:
some code
break;
case 3:
some code
break;
}
I need that then case 2 executes it will go back and execute case 1. or then case 3 executes i need it to go back and execute case 1.
Is it possible to do? Thank you!
If I understood correctly, something like this should work for you:
function duck($m)
{
switch($m){
case 1:
//some code
break;
case 2:
duck(1);
break;
case 3:
duck(1);
break;
}
}
duck(2);
Good luck!
It is possible if you set it up right:
switch($var){
case 1:
some code 1;
case 2:
some code 2;
break;
case 3:
some code 3;
default
some code 4;
break;
}
Basically, it will keep going down the flow of the switch til it reaches a break. So, in this example, case 2 will execute code 2, but case one will execute first code 1 THEN code 2, because there is no break. Same thing for case 3 and default: case 3 would hit both some code 3 and some code 4.