NYCPHP Meetup

NYPHP.org

[nycphp-talk] range in switch/case

Daniel Convissor danielc at analysisandsolutions.com
Thu Feb 5 13:48:27 EST 2004


Hi Chris:

On Thu, Feb 05, 2004 at 01:43:06PM -0500, 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.  But your cases can flow into each other:

switch () {
    case 1:
    case 2:
    case 3:
        // do something
        break;
    default:
        // do something else
}

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list