What is a true way to write like:
if ($variable == '(value1/value2/value3)' ) { }
It should work similar to:
if ($variable == 'value1' || $variable == 'value2' || $variable == 'value3') { }
Just want to make this code shorter (now I use switch).
Thanks.
Try
in_array():If you do happen to have a group of values separated by, in your example, a
/, justexplode()it and you’ll have an array to plug intoin_array():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 (useexplode()instead, as above):