如何学习php array_intersect_assoc() 定义和用法
array_intersect_assoc() 函数返回两个或多个数组的交集数组。
与 array_intersect() 函数 不同的是,本函数除了比较键值,还比较键名。返回的数组中元素的键名保持不变。
语法
array_intersect_assoc(array1,array2,array3...)
参数
描述
array1必需。与其他数组进行比较的第一个数组。
array2必需。与第一个数组进行比较的数组。
array3可选。与第一个数组进行比较的数组。可以有多个。
例子 1
cat,1=>dog,2=>horse); $a2=array(3=>horse,1=>dog,0=>cat); print_r(array_intersect_assoc($a1,$a2)); ?>
输出:
array ( [0] => cat [1] => dog )
例子 2
cat,1=>dog,2=>horse); $a2=array(3=>horse,1=>dog,5=>fish); $a3=array(6=>cow,1=>dog,8=>fish); print_r(array_intersect_assoc($a1,$a2,$a3)); ?>
输出:
array ( [1] => dog )
http://www.bkjia.com/phpjc/834962.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/834962.htmltecharticle如何学习php array_intersect_assoc() 定义和用法 array_intersect_assoc() 函数返回两个或多个数组的交集数组。 与array_intersect() 函数不同的是,本函数...