checking a variable against multiple values
Date: 03/09/06
(PHP Community) Keywords: no keywords
aside from dumping the values into an array and then using in_array(), is it possible to write a comparison statement that checks against multiple values? i often find myself doing something like
if ($x == 1 || $x == 2 || $x == 3) {
do_some_junk();
}
which seems kind of messy. it'd be nice if there was something like
if ($x in(1,2,3)) {
do_some_junk();
}
i've tried experimenting but haven't come up with anything.
Source: http://community.livejournal.com/php/423794.html