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


basically i'm wondering if there way shorten this:

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

in such way variable can tested against or compared multiple values without repeating variable , operator every time.

for example, along lines of might help:

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

or results in less typing.

in_array() use

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

Comments