multiple cases in switch statement
| From: | Asendorf, John | Date: | Thu, 21 Dec 2000 22:04:49 +0000 |
| Subject: | multiple cases in switch statement | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4583@lists.php.net to get a copy of this message | ||
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"):
$street .= "FIRST";
break;
case ("2ND" || "2"):
$street .= "SECOND";
break;
case "3RD":
$street .= "THIRD";
break;
case ("4TH" || "4"):
$street .= "FOURTH";
break;
default:
$street .= $num;
break;
}
echo $street;
Any suggestions on what I'm missing here? What's makes this very weird for
me is that the first case WORKS...
---------------------
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.