RE: [PHP] Switch Statement || Case with multiple values?
| From: | Martin Towell | Date: | Sun, 02 Mar 2003 23:46:04 +0000 |
| Subject: | RE: [PHP] Switch Statement || Case with multiple values? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-137813@lists.php.net to get a copy of this message | ||
I've been using this:
if (in_array($value, array("foo", "bar", "blah")))
{
// do something
}
but if you want to use a switch/case, I don't know any easier way.
HTH
Martin
> -----Original Message-----
> From: CF High [mailto:noah@newminddesign.com]
> Sent: Monday, March 03, 2003 1:41 PM
> To: php-general@lists.php.net
> Subject: [PHP] Switch Statement || Case with multiple values?
>
>
> Hey all.
>
> In Cold Fusion I was able to do the following:
>
> <CFSWITCH expression = #action#>
>
> <CFCASE value = "getUpdate,getDelete">
> Do Stuff........
> </CFCASE>
>
> </CFSWITCH>
>
> Note the comma delimited set of values for the case. Is
> there a way to do
> this in php?( i.e. if any of the comma delimited case values match the
> switch expression, proceed with the specified case instructions)
>
> It's kind of cumbersome breaking out 5 cases when in CF I can
> combine them
> into one........
>
> Let me know.
>
> --Noah
>
>
>
> --
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>