时间:2021-07-01 10:21:17 帮助过:5人阅读
代码如下:
$array = array("red"=>"Red","green"=>"red4","Red15"=>"Red",7=>"Level","Width"=>"Red","azzzz1"=>"art","peak"=>158);
$array1 = array("red"=>"Red2","greena"=>"red","Red15"=>"Red",7=>"Level","Width"=>"Red","azzzz"=>"art","peak"=>158);
$num = array_intersect($array,$array1);
print_r ($num);
echo "
";
$num = array_intersect_assoc($array,$array1);
print_r($num);
echo "
";
$num = array_intersect_key($array,$array1);
print_r ($num);
?>
代码如下:
Array ( [red] => Red [Red15] => Red [7] => Level [Width] => Red [azzzz1] => art [peak] => 158 )
Array ( [Red15] => Red [7] => Level [Width] => Red [peak] => 158 )
Array ( [red] => Red [Red15] => Red [7] => Level [Width] => Red [peak] => 158 )
以上就介绍了colesafearray PHP数组的交集array_intersect,array_intersect_assoc,array_inter_key函数的小问题,包括了colesafearray方面的内容,希望对PHP教程有兴趣的朋友有所帮助。