php数组过滤器重复,其中value1和value2分别是value1和value2

时间:2018-09-14 09:41:20

标签: arrays duplicates multiple-columns

我正在尝试过滤数组中的重复项。

目前,我可以通过以下方式使用1个值进行过滤:

$json = json_encode($inBounds);
$arr = json_decode($json,true);
$nodupes = array_column($arr, Null, "limit_lat");
$count = array_count_values(array_column($arr, "limit_lat"));

foreach ($count as $key => $c){
if($c <10){
$sizeIcon= 'icon1';
}
if($c >10 && $c <100){
$sizeIcon= 'icon10';
}   
if($c >100 && $c <1000){
$sizeIcon= 'icon100';
}
if($c >1000 && $c <10000){
$sizeIcon= 'icon1000';
}   
if($c >10000){
$sizeIcon= 'icon10000';
}   

if($c === 1){   
     $nodupes[$key]['count'] = '';
     $nodupes[$key]['sizeIcon'] = $sizeIcon;
}else{
     $nodupes[$key]['count'] = $c;   
     $nodupes[$key]['sizeIcon'] = $sizeIcon;
     }
}
$nodupes = array_values($nodupes);

当前我正在过滤“ limit_lat”,但现在还需要过滤“ limit_lng”

因此,仅当(limit_lat和limit_lng)为(limit_lat和limit_lng)时,才会删除(计数)重复对象。

我的json:

[{"id":18,"lat":"50.84757300","lng":"5.71289100","name":"Dennis","date":"2018-09-14 11:14:34","sizeIcon":"icon1","limit_lat":"51","limit_lng":"6","count":""},{"id":19,"lat":"51.06901700","lng":"-62.66601600","name":"Test","date":"2018-09-14 11:14:42","sizeIcon":"icon1","limit_lat":"51","limit_lng":"-63","count":""}]

您能帮我吗? 谢谢, 丹尼斯

0 个答案:

没有答案