Re: The || Operator (alternatives to the)
| From: | Joel Rees | Date: | Mon, 26 May 2003 07:21:54 +0000 |
| Subject: | Re: The || Operator (alternatives to the) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148956@lists.php.net to get a copy of this message | ||
> $you = "some";
> if ($you == ("few" || "some" || "one")) {
> echo "yes";
> }else{
> echo "no";
> }
>
> How can I make it print out "yes" if $you is equal to "few",
> "some", or
> "one"?
One more option, may be useful if your list is long, or if your
association is to more than just "yes" --
$someWords =
array(
"few" => "yes",
"some" => "yes",
"one" => "yes",
"many" => "maybe"
);
$you = "some";
$theWord = $someWords[ $you ];
if ( isset( $theWord ) )
{ echo $theWord;
}
else
{ echo "no";
}
--
Joel Rees, programmer, Kansai Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp