switch statement help (php)

Associate
Joined
18 Sep 2003
Posts
2,368
so I have the code:

case 1: echo "1"; break;
case 2: echo "2"; break;
case 3: echo "3"; break;
case 4: echo "4"; break;
case 5: echo "5"; break;



how do I prevent the code from being executed after the first case statement has been met? If condition 3 is met, I don't 4 or 5 to execute regardless. How do I modify the code to stop this?

thanks
 
The whole point of the command is to only execute the first option that matches, then exit the loop. You don't have to do anything. Well, apart from break; as mentioned above
 
no it isn't. you don't have to break if you want a set of actions to be applied to the same thing if it fits multiple criteria.
 
Back
Top Bottom