PHP 二维数组
Array留哪个呢?还是2个 tag_id 都要?
不用只要一个数组[0] => Array
(
[knowledge_id] => 1
[tag_id] => 2
)
设原数组为 $ar, 则
$res = array(); //结果数组foreach($ar as $v) { if(! isset($res[$v['knowledge_id']])) $res[$v['knowledge_id']] = $v;}$res = array_values($res);