NYCPHP Meetup

NYPHP.org

[nycphp-talk] range in switch/case

Chris Bielanski Cbielanski at inta.org
Thu Feb 5 16:45:49 EST 2004


Yeah, that's true, but any control structure that needs (TRUE) as a running
condition is IMHO a Bad Thing(tm)...
 

Thanks, 
Chris Bielanski - [CBielanski at inta.org] 
Web Programmer, 
International Trademark Association - [www.inta.org] 
1133 Ave. of the Americas - Manhattan 
p - 212/642-1745 



-----Original Message-----
From: Ophir Prusak [mailto:lists at prusak.com]
Sent: Thursday, February 05, 2004 4:38 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] range in switch/case



If you really want to use switch, you can use use switch (TRUE) and in the
case something like ($a < 10 && $a > 100).
It's not really any better than if / elseif, but it looks cool :)

Ophir


Chris Bielanski wrote:


Cool, just wanted a definitive 'no' :) As it is, I don't really care if the

user manages to jam some odd value in there since it's building a SELECT

statement and nothing "dangerous".



Hooray for 'default' case!! :P



Thanks!

Chris Bielanski - [ CBielanski at inta.org <mailto:CBielanski at inta.org> ]

Web Programmer, 

International Trademark Association - [ www.inta.org <http://www.inta.org> ]

1133 Ave. of the Americas - Manhattan

p - 212/642-1745











-----Original Message-----

From: Adam Maccabee Trachtenberg [ mailto:adam at trachtenberg.com
<mailto:adam at trachtenberg.com> ]

Sent: Thursday, February 05, 2004 1:46 PM

To: NYPHP Talk

Subject: Re: [nycphp-talk] range in switch/case





On Thu, 5 Feb 2004, Chris Bielanski wrote:



  

I'm being lazy - in Pascal/Delphi you can assign a range as a case in a

switch statement. for example... case(0..255) or case('A'..'Z').



Does PHP have a facility to do this? I note that the above doesn't like me

very much ;)

    



No. Switch to an if()...elseif()...else() and use a regular expression

character class or something similar inside the if().



There was a brief talk of adding this to PHP, but it was rejected.



-adam



  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040205/45096c92/attachment.html>


More information about the talk mailing list