First time trying to find something in an array using an array as both a needle and a haystack. So, example of 2 arrays:
My Dynamically formed array:
Array (
[0] =>
[1] => zpp
[2] => enroll
)
My Static comparison array:
Array (
[0] => enroll
)
And my in_array() if statement:
if (in_array($location_split, $this->_acceptable)) {
echo 'found';
}
$location_split; // is my dynamic
$this->_acceptable // is my static
But from this found is not printed out, as I’d expect it to be? What exactly am I failing on here?
If i’m understanding you right, you want to see whether the first array’s entries are present in the second array.
You might look at
array_intersect, which would return you an array of stuff that’s present in all the arrays you pass it.If the count of that array is at least 1, then there’s at least one element in common. If it’s equal to your dynamic array’s length, and the array’s values are distinct, then they’re all in there.
And, of course, the array will be able to tell you which values matched.