I have a multiple array, like the follow example.
$array = array (
\'role_1\' =>
array (
0 => \'value_2\',
1 =>
-
You can use array_intersect to cover the dynamic $data
as such:
$data = array (
'role_1' =>
array (
0 => 'value_2',
1 => 'value_3',
),
'role_2' =>
array (
0 => 'value_1',
1 => 'value_2',
),
'role_3' =>
array (
0 => 'value_2',
1 => 'value_3',
)
);
$result = call_user_func_array('array_intersect', $data);
call_user_func_array will help spread the elements of your array as parameters inside array_intersect
.
- 热议问题