RE: [PHP-WIN] multiple cases in switch statement
| From: | Asendorf, John | Date: | Fri, 22 Dec 2000 13:18:46 +0000 |
| Subject: | RE: [PHP-WIN] multiple cases in switch statement | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4600@lists.php.net to get a copy of this message | ||
Matt, Mark and Cynic:
Thanks that what I was looking for... it was right there in the damn
annotated manual and I missed it...
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
The benefit to the government of replacing all $1 Federal Reserve notes with
$1 coins would be $522.2 million per year, according to estimates of the
General Accouting Office released on April 7, 2000.
> -----Original Message-----
> From: Mark Maggelet [mailto:maggelet@mminternet.com]
> Sent: Thursday, December 21, 2000 5:42 PM
> To: jasendorf@lcounty.com; php-windows@lists.php.net
> Subject: Re: [PHP-WIN] multiple cases in switch statement
>
>
> On Thu, 21 Dec 2000 17:04:49 -0500, Asendorf, John
> (jasendorf@lcounty.com) wrote:
> >Hello all...
> >
> >I'm running a little address checker and attempting to catch ordinal
> >numbers
> >(first, second, third, etc) by catching multiple instances such as
> >
> >1st or 1 gives us FIRST
> >
> >so far I have this... the worst part about it is that part of this
> >is
> >working and the rest is not... when I enter "1" or "1ST" into it, I
> >get
> >FIRST back...
> >
> >when I enter "2ND" or "2" I get nothing back (not even the default
> >no error,
> >no nothin)...
> >
> >when I enter "3RD" I get THIRD back...
> >
> >When I enter "4TH" or "4" I get nothing back (not even the default
> >no error,
> >no nothin)...
> >
> > if ( eregi ( "[0-9]{1,2}([a-zA-Z])*" ,$num ) ) {
> > //echo "hit the switch";
> > switch ($num) {
> > case ("1ST" || "1"):
>
> this line will evaluate to either "case 1:" or "case true:"
> what you really want to do is something like this:
> switch($num){
> case "1ST": case "1": $street .= "FIRST"; break;
> case "2ND": case "2": $street .= "SECOND"; break;
> ...
> }
>
> - Mark
>