Switch Question...

From: Date: Mon, 15 Nov 2010 21:27:42 +0000
Subject: Switch Question...
Groups: php.general 
Request: Send a blank email to php-general+get-309494@lists.php.net to get a copy of this message
Ok, dumb question, and i have tested, but I want to ensure that my tests were accurate, and behavior is correct. Ok, i have an integer, that based on what it is, does certain things... switch ((int)$intval) { } now, if i need to do something on a few of the numbers, then: case 0: # do nothing as strings will be (int) as 0 break; case 1: # do this break; case 12: # do this break; default: # do everything that is general to this which this works, as the $intval should never be anything that i am not expecting as there is another part of the code that decides which int's to send to this class. but is there a better way to do this? this could potentially do a lot more, and be more dynamic, but there is also the possibilty that i need to have more "custom" commands based on an integer value, and not something that is "generic". Is there a way to only do from like cases 2-11, without doing: case 2: case 3: case 4: ..... case 11: # do this stuff break; am I just overthinking things? i dunno... it's monday... brains still on weekend mode. Steve

« previous php.general (#309494) next »