array_intersect_assoc推荐查看本文HTML版本
(PHP 4 >= 4.3.0) array_intersect_assoc -- 带索引检查计算数组的交集 说明[月影读书频道 http://wf66.com/] array array_intersect_assoc ( array array1, array array2 [, array ...]) array_intersect_assoc() 返回一个数组,该数组包含了所有在 array1 中也同时出现在所有其它参数数组中的值。注意和 array__intersect() 不同的是键名也用于比较。
例子 1. array_intersect_assoc() 例子 <?php $array1 = array ("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array ("a" => "green", "yellow", "red"); $result_array = array_intersect_assoc ($array1, $array2); /* $result_array will look like: Array ( [a] => green ) */[月影社区 http://wf66.com/] ?> 上面例子中可以看到键值对 "a" => "green" 在两个数组中都有因此被返回。值 "red" 没有被返回是因为在 $array1 中他的键名是 2 而在 $array2 中 "red" 的键名是 1。
键值对 key => value 中的两个值仅在 (string) $elem1 === (string) $elem2 时被认为相等。也就是说使用了严格检查,字符串的表达必须相同。 参见 array_intersect[月影社区 http://wf66.com/]
|