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 <b>{$states[$state]}</b>, a state in the pacific NW!"; } else { echo "you've chosen <b>$state</b>, an inferior state indeed."; } In the above, we make sure the chosen state is a $states key/index as array_keys creates an array of keys, from the $states array, like so : $keys = array('WA','OR','ID'); If $state is in this array, bingo! That's one way, it all depends on what you're doing exactly. in_array() is a nice little function btw, that's the point of this post :) Check out array_keys and array_search too. regards, philip On Sun, 13 May 2001, DRN wrote: > 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 there a better way of doing this? I will > occasionally need to add another option as well, although I don't mind > a simple code edit. > > > Cheers for your help, Donald > __________________________________________ > As well as learning more, > I learn that there is even more I don't know > > http://www.donaldrnoble.f2s.com > ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]