我有一个多维数组,我需要交叉检查它是否有重复结果,如果它们重复,则使用重复结果删除数组。我需要检查3个密钥是否有重复;号码,出发和到达。这里是一个示例阵列,其中第三个阵列是重复的,需要删除:检查多维数组中的重复结果
[Cars] => Array
(
[0] => Array
(
[cartype] => car1
[number] => 123
[craft] => 456
[departure] => GHY
[departtime] => 20:25
[arrival] => PUI
[arrivetime] => 22:50
)
[1] => Array
(
[cartype] => car2
[number] => 567
[craft] => 890
[departure] => LHY
[departtime] => 16:25
[arrival] => PGY
[arrivetime] => 23:50
)
[2] => Array
(
[cartype] => car2
[number] => 567
[craft] => 890
[departure] => LHY
[departtime] => 16:25
[arrival] => PGY
[arrivetime] => 23:50
)
)
我真的很感谢一些帮助。
谢谢,
你必须检查所有的数组元素,或者只是'number'? – Barmar
您可以使用'serialize()'将每个数组转换为一个字符串,使用'array_unique()'移除重复项,然后使用'unserialize()'将它们转换回数组。 – Barmar
http://stackoverflow.com/questions/307674/how-to-remove-duplicate-values-from-a-multi-dimensional-array-in-php – bxN5