📜  php 数组连接 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:52.390000             🧑  作者: Mango

代码示例6
$array1 = [1, 5, 64, 2, 6];
$array2 = [2, 1, 8, 3];

//Method 1:
array_filter($array1, function($_){
    global $array2;
  return in_array($_, $array2);
}); // Output: [0 => 1, 3 => 2]

//Method 2:
array_intersect($array1, $array2); //Output: [0 => 1, 3 => 2]