[nycphp-talk] switch cases
Jake McGraw
jmcgraw1 at gmail.com
Sat Dec 1 13:59:12 EST 2007
I've found the following useful if you don't want to use a bunch of if /
else if but you need to do more than a simple comparison:
switch(true) {
case ($a=='a') : // Behaves like a normal switch
break;
case ($a===1) : // Strict check
break;
case ($a>$b) : // Do whatever test you'd like
break;
}
- jake
On Dec 1, 2007 1:23 PM, David Krings <ramons at gmx.net> wrote:
> Ken Robinson wrote:
> > At 12:23 PM 12/1/2007, David Krings wrote:
> >> Hi!
> >>
> >> I make use of a switch statement, but now need to execute the same
> >> code of one case for a different case (it is a switch on a file type
> >> and some types are to be handled the same). I know how to craft this
> >> case using if, but how would I do that with using case within a switch?
>
> > You would list each case, one after another:
> >
> > switch ($a) {
> > case 'a':
> > case 'b':
>
> Now that was far too easy! Thank you very much!
>
> David
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20071201/acb72a0f/attachment.html>
More information about the talk
mailing list