Re: multiple cases in switch statement
| From: | Toby Butzon | Date: | Thu, 21 Dec 2000 22:18:19 +0000 |
| Subject: | Re: multiple cases in switch statement | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-4584@lists.php.net to get a copy of this message | ||
Try this
if ( eregi ( "[0-9]{1,2}([a-zA-Z])*" ,$num ) )
// echo "Switching for $num.... ";
switch ($num) {
case (1):
$street .= "FIRST";
break;
case 2:
$street .= "SECOND";
break;
case 3:
$street .= "THIRD";
break;
case 4:
$street .= "FOURTH";
break;
default:
$street .= $num;
break;
}
}
echo $street;
Toby Butzon
[ criticism spurs improvement ]
----- Original Message -----
From: "Asendorf, John" <JAsendorf@lcounty.com>
To: "Php-Windows (E-mail)" <php-windows@lists.php.net>
Sent: Thursday, December 21, 2000 5:04 PM
Subject: [PHP-WIN] multiple cases in switch statement
: 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 ) )
: file://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.
:
:
: --
: PHP Windows Mailing List (http://www.php.net/)
: To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
: For additional commands, e-mail: php-windows-help@lists.php.net
: To contact the list administrators, e-mail: php-list-admin@lists.php.net
:
: