Reputation: 302
I have the following array that contains other arrays:
$bigArray = [$array_one, $array_two, $array_three,.... ];
I want to array_intersect
the inner arrays like so:
$intersect = array_intersect($array_one, $array_two, $array_three,....);
How do I handle it?
Upvotes: 1
Views: 120
Reputation: 41810
Like this:
$intersect = array_intersect(...$bigArray);
The ...
operator, introduced in PHP 5.6, allows you to use an array to pass multiple function arguments.
It's also possible to do this with call_user_func_array
, but argument unpacking offers some advantages over that approach.
Upvotes: 4
Reputation: 302
call_user_func_array('array_intersect', $bigArray);
this works for me
Upvotes: 1