本文介绍了根据从另一个数组键array_filter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有两个数组: $ ARR1 =阵列('A'=> 10,'B'=→20); $ ARR2 =阵列('A'=> 10,'B'=> 20,'C'=> 30); 我如何使用array_filter下降从 $ ARR2 元素不 $ ARR1 存在吗?就像在我的例子C...... 解决方案 有是专门为此做了一个功能:的 array_intersect():$arr2 = array_intersect($arr1, $arr2);If you want to compare keys, not the values like array_intersect(), use array_intersect_key():$arr2 = array_intersect_key($arr1, $arr2); If you want to compare key=>value pairs, use array_intersect_assoc():$arr2 = array_intersect_assoc($arr1, $arr2); 这篇关于根据从另一个数组键array_filter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 13:47