When giving PHP
in_array an array of values I want to search for, it does not work. Although the documentation specifies that you can give a <em>
So basically I want to test for the presence of multiple terms as the value of an array - is there a reason this is not working, and can anyone suggest another way of doing this?Answer1:
mixed doesn't mean more than one needle, it refers to types. It's documentation talk for more than one possible type.Answer2:
For something like searching an array $haystack for multiple $needles that are all strings or numbers, you can use
array_intersect($array1, $array2, ...)
<a href="http://php.net/manual/en/function.array-intersect.php" rel="nofollow">http://php.net/manual/en/function.array-intersect.php</a>
It should work for mixed types also.Answer3:
When the documentation says
mixed it means it can accept multiple types, e.g.
string. Though the docs should say exactly which types are valid.