PHP数组的区别 [英] php array difference

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

问题描述

我试图找到2阵列的区别。

  $ inven_old =阵列(1,2,3,4);
$ inven_new =阵列(1,2,3,4,5);
$结果=和array_diff($ inven_old,$ inven_new);
的print_r($结果);

为什么是什么结局?

难道不应该是5?

如果没有,我该怎么办我想要做什么?


解决方案

  

返回一个包含了所有在array1不在任何其他阵列present条目的数组。


<一个href=\"http://php.net/manual/en/function.array-diff.php\">http://php.net/manual/en/function.array-diff.php

和array_diff()给减去所有阵列除了第一个,从第一的结果。因此,事情是第二个数组中,但不是第一个也不会显示出来。 (换句话说,它不是的对称的区别。)

I'm trying to find the difference in 2 arrays.

$inven_old = array(1,2,3,4); 
$inven_new = array(1,2,3,4,5); 
$result = array_diff($inven_old, $inven_new); 
print_r($result);

Why is the outcome nothing?

Shouldn't it be "5" ?

If not, how can I do what I'm trying to do?

解决方案

Returns an array containing all the entries from array1 that are not present in any of the other arrays.

http://php.net/manual/en/function.array-diff.php

array_diff() gives the result of subtracting all arrays except the first, from the first. Thus, things which are in the second array but not the first won't show up. (In other words, it's not the symmetric difference.)

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

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