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. 回答1: in_array() is what I use if (in_array(