我想删除数组中的重复项。在下面的数组中,我想删除数组(500)中的重复STRIP。
Array ( [125] => Array ( [0] => STRIP ) [250] => Array ( [0] => STRIP ) [333] => Array ( [0] => STRIP ) [500] => Array ( [0] => STRIP [1] => STRIP ) [] => Array ( [0] => BOTTLE [1] => STRIP ) )
我的预期输出将是
Array
(
[125] => Array
(
[0] => STRIP
)
[250] => Array
(
[0] => STRIP
)
[333] => Array
(
[0] => STRIP
)
[500] => Array
(
[0] => STRIP
)
[] => Array
(
[0] => BOTTLE
[1] => STRIP
)
)
答案 0 :(得分:1)
这是你需要的吗?
<?php
foreach($arr as $k=>$v){
$newArray[$k]=array_unique($v);
}
print_r($newArray);
?>
答案 1 :(得分:1)
答案 2 :(得分:1)
$newArray = array();
foreach($arr as $k=>$v){
$newArray[$k]=array_values(array_unique($v));
}
print_r($newArray);