Get intersection of a multiple array in PHP

前端 未结 3 1398
有刺的猬
有刺的猬 2021-01-13 22:22

Starting Point

I have a multiple array, like the follow example.

$array = array (
  \'role_1\' => 
  array (
    0 => \'value_2\',
    1 =>         


        
3条回答
  •  执笔经年
    2021-01-13 22:28

    You should be able to do

    call_user_func_array('array_intersect', $array_of_arrays)
    

    This will pass each element of your array of arrays as an argument to array_intersect, which takes a variable number of arrays as arguments and returns their intersection.

提交回复
热议问题