[0] => Array
(
[feature code] => PPL
[country code] => ES
[admin1code] => 51
[admin2code] => H
[name] => Zalamea la Real
[asciiname] => Zalamea la Real
[id] => 108164
)
[1] => Array
(
[feature code] => PPLA3
[country code] => ES
[admin1code] => 51
[admin2code] => H
[name] => Zalamea la Real
[asciiname] => Zalamea la Real
[id] => 108188
)
我的数组有类似的重复项,其中名称值是重复的值,而不是。
如何取消所有重复但留下一个?
答案 0 :(得分:0)
您可以尝试:
$repeating = [];
foreach ($data as $key => $value) {
if(in_array($value['name'], $repeating)) {
unset($data[$key]['name']);
}
else {
$repeating[] = $value['name'];
}
}