I have the following array:
Array
(
[0] => Array
(
[0] => 87
[1] => 58
[2] => 85
[3] => 86
)
[1] => Array
(
[0] => 58
[1] => 84
)
[2] => Array
(
[0] => 58
)
)
This array above is an example. The actual array is of variable size, but structured like this. Basically, I'd like to run array_intersect
on each second level array and grab the value (number) that is common between them. In this case, it would be 58
.
I'm not quite sure where to start on this. Any advice?
This works for me:
Should get you:
The above will work if you have a common number in at least two of the sub-arrays.
After your edit:
You can simply use
call_user_func_array
onarray_intersect
, if you want to find numbers that are contained in all sub-arrays: