您好我有以下数组
Array
(
[k1] => Array
(
[0] => banana
[1] => mango
[2] => orange
[3] => orange
)
[k2] => Array
(
[0] => adaL
[1] => ada
[2] => dad
[3] => dad
)
)
现在我想删除像ORANGE这样的重复条目。我该怎么做?
答案 0 :(得分:5)
$a = array_map('array_unique', $a);
答案 1 :(得分:1)
您正在寻找array_unique
$k1 = array('banana', 'mango', 'orange', 'orange');
$k1 = array_unique($k1);
哪个会给你
array
0 => string 'banana' (length=6)
1 => string 'mango' (length=5)
2 => string 'orange' (length=6)
答案 2 :(得分:1)
foreach ($array as &$value) {
$value = array_unique($value);
}