来自用户我得到了一个像这样的多维数组:
Array (
[classCode] => Array (
[0] => class44
[1] => class67
[2] => class34
[3] => class34
[4] => class44
)
[className] => Array (
[0] => phy
[1] => mat
[2] => chy
[3] => sci
[4] => phy
)
)
我需要在数组中找到重复的值,还应该考虑' [classCode]'作为主键,应该返回如下所示的数组。
Array (
[classCode] => Array (
[0] => class44
[1] => class67
[2] => class34
)
[className] => Array (
[0] => phy
[1] => mat
[2] => chy
)
)
答案 0 :(得分:1)
使用array_map
:
$result = array_map(function ($items) {
return array_unique($items);
}, $your_array);