如何比较两个数组的值?

时间:2021-04-01 12:02:05

I have 2 arrays one retrieved from a database (saved results) and the other from an xml (new results)

我有两个数组,一个是从数据库中检索出来的(保存的结果),另一个是来自xml(新结果)

$fromDB = array('123','124','524','15','616');
$fromXML = array('123','124','524','15','818');

I want to compare those two and see which values are old (fromDB) and which are new (fromXML) so to insert the old value in a different table.

我想比较这两个值,看看哪个值是旧的(fromDB),哪个值是新的(fromXML),以便将旧值插入到另一个表中。

How can i achieve this?

我如何做到这一点?

2 个解决方案

#1


3  

The array_diff function is what you're looking for.

array_diff函数就是我们要找的。

#2


2  

Take a look at the array_diff() function

看一下array_diff()函数

#1


3  

The array_diff function is what you're looking for.

array_diff函数就是我们要找的。

#2


2  

Take a look at the array_diff() function

看一下array_diff()函数