In PHP, is there a short way to compare a variable to multiple values?

Basically what I'm wondering if there is a way to shorten something like this:

if ($variable == "one" || $variable == "two" || $variable == "three")

in such a way that the variable can be tested against or compared with multiple values without repeating the variable and operator every time.

For example, something along the lines of this might help:

if ($variable == "one" or "two" or "three")

or anything that results in less typing.

Answers


in_array() is what I use

if (in_array($variable, array('one','two','three'))) {

Need Your Help

Bash grep local IP address and write to file in makefile?

bash makefile ifconfig

I'm trying to get my local ip with ifconfig and write it to file but for some reason fail to do so.