In PHP, the in_array() function only allows for checking the presence of a single value.
How do I check for multiple values at the same time?
Please provide the answer for both cases:
- Checking if all values are present in the array
- Checking if at least one value is present in the array
Intersect the targets with the haystack and make sure the intersection count is equal to the target’s count:
Note that you only need to verify the size of the resulting intersection is the same size as the array of target values to say that
$haystackis a superset of$target.To verify that at least one value in
$targetis also in$haystack, you can do this check: