【发布时间】:2015-12-11 03:31:48
【问题描述】:
我有两个数组,例如:
array (size=4)
0 => string '5' (length=1)
1 => string '4' (length=1)
2 => string '2' (length=1)
3 => string '2' (length=1)
3 => string '8' (length=1)
还有一个我从 XML 文件加载的数组:
object(SimpleXMLElement)[1]
public 'book' =>
array (size=101)
0 =>
object(SimpleXMLElement)[2]
public 'id' => string '1' (length=1)
public 'title' => string 'p' (length=1)
1 =>
object(SimpleXMLElement)[3]
public 'id' => string '2' (length=1)
public 'title' => string 'pp' (length=2)
2 =>
object(SimpleXMLElement)[4]
public 'id' => string '3' (length=1)
public 'title' => string 'pen' (length=3)
3 =>
object(SimpleXMLElement)[5]
public 'id' => string '4' (length=1)
public 'title' => string 'lapton' (length=6)
......
......
101 =>
object(SimpleXMLElement)[103]
public 'id' => string '101' (length=1)
public 'title' => string 'title' (length=5)
我想将第二个数组的键 id 的每个值与每个值的第一个数组的键进行比较。当它相同时,我想更新第二个数组的键title的值。
【问题讨论】:
-
PHP compare array的可能重复
-
我认为不一样,就我而言,我想比较每个数组的每个值。就像多对多