What's the easiest way to write an if statement that declares a variable must be one of many things? IE: if ($variable == red, orange, or yellow) { $variable == warm color } ? In my code I need to test if a variable is one of 6 or so things. What's the best way to code this?
Thanks!
If a variable is one of many things
Moderator: General Moderators
Re: If a variable is one of many things
from php.net
Code: Select all
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
Re: If a variable is one of many things
Perfect! Thanks!