You could also try using a regular expression to get out whatever you need
(if it's a string). Something like the following:
preg_match_all("/[abc|def|ghi]/",$type, $matches);
- Steve
""DRN"" <[EMAIL PROTECTED]> wrote in message
9dkhdr$nog$[EMAIL PROTECTED]">news:9dkhdr$nog$[EMAIL PROTECTED]..
Here's an appropriate example, one of a few ways you may do it :
$state = 'Wa';
$state = trim(strtoupper($state));
$states = array('WA' => 'Washington', 'OR' => 'Oregon', 'ID' => 'Idaho');
if (in_array($state, array_keys($states))) {
echo "you chose {$states[$state]}, a state in
How about a case-swtich?
http://www.php.net/manual/en/control-structures.switch.php
Ethan Schroeder
- Original Message -
From: "DRN" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 12, 2001 4:40 PM
Subject: [PHP] check if a variable is in a numbe
Hi, I would like to check whether a variable, $type, is equal to a
number of different possible states. I know I could use
if ( $type == "abc" || $type == "bcd") { $a = b }
but this would get a bit clumsy if I had to check whether it is say
one of 20 different things.
What I was wondering is, is
4 matches
Mail list logo