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? 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 } } 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 Link to comment https://forums.phpfreaks.com/topic/137041-switch-statement/#findComment-715742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.