php二维数组去除重合数据
Array
(
[0] => Array
(
[knowledge_id] => 1
[tag_id] => 2
)
[1] => Array
(
[knowledge_id] => 1
[tag_id] => 3
)
)
把他里面量相同的[knowledge_id] => 1合并只留一个??????
------解决方案--------------------设原数组为 $ar, 则
$res = array(); //结果数组
foreach($ar as $v) {
if(! isset($res[$v['knowledge_id']])) $res[$v['knowledge_id']] = $v;
}
$res = array_values($res);