我已经尝试了好几个小时了。
我有两个多维数组
$newData (
[0] => Array(
[id] => 1
[name] => John
[sex] => male
)
[1] => Array(
[id] => 2
[name] => Kenny
[sex] => male
)
[2] => Array(
[id] => 3
[name] => Sarah
[sex] => female
)
[3] => Array(
[id] => 4
[name] => George
[sex] => male
)
)
$oldData (
[0] => Array(
[id] => 3
[name] => Sarah
[sex] => female
)
[1] => Array(
[id] => 4
[name] => George
[sex] => male
)
[2] => Array(
[id] => 5
[name] => Peter
[sex] => male
)
[3] => Array(
[id] => 6
[name] => Lexi
[sex] => female
)
)
我需要比较 $newData 和 $oldData 并只获取第一个公共数组之前的新数据。
然后我的 $newData 将是:
$newData (
[0] => Array(
[id] => 1
[name] => John
[sex] => male
)
[1] => Array(
[id] => 2
[name] => Kenny
[sex] => male
)
)
如果比较 ID 键但没有任何工作正常,我已经尝试了 array_unique 中的所有内容。
我需要先合并它们吗?映射它们?呸,我不知道,我迷路了。
任何帮助都是极好的