两个数组之间的差异 [英] difference between two arrays

查看:91
本文介绍了两个数组之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下两个数组.我想要这两个数组之间的区别.也就是说,如何找到两个数组都不存在的值?

I have following two arrays. I want the difference between these two arrays. That is, how can I find the values that do not exist in both arrays?

 $array1=Array ( [0] => 64 [1] => 98 [2] => 112 [3] => 92 [4] => 92 [5] => 92 ) ;
 $array2=Array ( [0] => 3 [1] => 26 [2] => 38 [3] => 40 [4] => 44 [5] => 46 [6] => 48 [7] => 52 [8] => 64 [9] => 68 [10] => 70 [11] => 72 [12] => 102 [13] => 104 [14] => 106 [15] => 92 [16] => 94 [17] => 96 [18] => 98 [19] => 100 [20] => 108 [21] => 110 [22] => 112);

推荐答案

注意:此答案将返回$array2中不存在的值,但不会返回$array1中的值. $array1中的值,而不是$array2中的值.

Note: this answer will return the values in $array2 that are not present in $array1, it will not return the values in $array1 that are not in $array2.

$diff = array_diff($array2, $array1);

array_diff()

这篇关于两个数组之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆