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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -