in_array as a case in a switch statement
Posted: Tue Dec 16, 2008 12:33 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hey folks, first post here as I'm running into some new issues during my development as of late.
so thanks in advance for taking a look
Basically, i have a switch statement that is looking for an ID #.
I have a certain scenario where the result will be the same for multiple ID#'s.
Can i create an array of these ID's and use it in a single case?
For example:
Thanks again! 
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hey folks, first post here as I'm running into some new issues during my development as of late.
so thanks in advance for taking a look
Basically, i have a switch statement that is looking for an ID #.
I have a certain scenario where the result will be the same for multiple ID#'s.
Can i create an array of these ID's and use it in a single case?
For example:
Code: Select all
$id_array = array(7,8,9,23);
Switch (ID){
case 1:
do stuff;
break;
case 2:
do stuff;
break;
case in_array($id_array):
do stuff;
break;
}~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: