使用array_diff(),如何从array2而不是array1中获取差异?
我正在尝试像这样使用 array_diff.这是我的两个数组输出:
I'm trying to use array_diff like so. Here are my two array outputs:
列表 1 输出
Array ([0] => 0022806 )
列表 2 输出
Array ([0] => 0022806 [1] => 0023199 )
PHP
$diff = array_diff($list_1, $list_2);
print "DIFF: " . count($diff) ."<br>";
print_r($diff);
输出是:
DIFF: 0
Array ( )
知道我做错了什么吗?为什么没有返回0023199
?
Any idea what I'm doing wrong? Why is 0023199
not returned?
推荐答案
array_diff() 中参数的顺序很重要
The order of arguments in array_diff() is important
返回一个数组,其中包含 array1 中所有不属于存在于任何其他数组中
Returns an array containing all the entries from array1 that are not present in any of the other arrays
相关文章