Try in_array()
:
if (in_array($variable, array('value1', 'value2', 'value3'))) {}
If you do happen to have a group of values separated by, in your example, a /
, just explode()
it and you'll have an array to plug into in_array()
:
if (in_array($variable, explode('/', 'value1/value2/value3'))) {}
It might seem like you could just use strpos()
instead since it's a long string of values, but that's not how one would work with a delimited string of multiple values (use explode()
instead, as above):
if (strpos('value1/value2/value3', $variable) !== false) {}