我喜欢在不使用的情况下比较两个数组,in_array
因为这两个数组都非常大(超过 50,000 个)。我喜欢生成一个新数组,其中包含第一个数组中缺少的所有数组。
我将使用的最快最有效的解决方案是什么?
第一个数组
从 SQL 查询生成的多维数组
Array (
[0] => Array (
[id] => 17228219
[name] => ...
)
[1] => Array (
[id] => 17228220
[name] => ...
)
[2] => Array (
[id] => 17228221
[name] => ...
)
[3] => Array (
[id] => 17228222
[name] => ...
)
[4] => Array (
[id] => 17228223
[name] => ...
)
[5] => Array (
[id] => 17228224
[name] => ...
)
)
从简单 XML 生成的第二个数组
Array (
[0] => SimpleXMLElement Object (
[0] => 17228219
)
[1] => SimpleXMLElement Object (
[0] => 17228221
)
[2] => SimpleXMLElement Object (
[0] => 17228222
)
[3] => SimpleXMLElement Object (
[0] => 17228224
)
)
新数组
创建一个缺少 ID 的数组
Array (
[0] => Array (
[id] => 17228220
[name] => ...
)
[1] => Array (
[id] => 17228223
[name] => ...
)
)