Bopo Posted December 15, 2008 Share Posted December 15, 2008 Hi New to PHP, just wondering if a switch statement can accommodate a value range, below is an example in pseudo code case 10 to 15 //do something case 16 to 21 //do something So its their anything like this available in switch statement? Quote Link to comment https://forums.phpfreaks.com/topic/137041-switch-statement/ Share on other sites More sharing options...
JonnoTheDev Posted December 15, 2008 Share Posted December 15, 2008 yes $x = 11; switch($x) { case ($x >= 10 && $x <= 15) { // code } case ($x >= 16 && $x <= 21) { // code } } Quote Link to comment https://forums.phpfreaks.com/topic/137041-switch-statement/#findComment-715740 Share on other sites More sharing options...
Bopo Posted December 15, 2008 Author Share Posted December 15, 2008 Yep that's what I'm looking for, thanks Quote Link to comment https://forums.phpfreaks.com/topic/137041-switch-statement/#findComment-715742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.