时间:2021-07-01 10:21:17 帮助过:15人阅读
$items = array(
array('dna_id'=>55,'status'=>1),
array('dna_id'=>55,'status'=>0),
array('dna_id'=>56,'status'=>1),
array('dna_id'=>58,'status'=>0),
array('dna_id'=>58,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0)
);
array(
'active'=>array('count'=>3,'ids'=>array('55','58','60')),
'completed'=>array('count'=>1,'ids'=>array('56'))
);
$items = array(
array('dna_id'=>55,'status'=>1),
array('dna_id'=>55,'status'=>0),
array('dna_id'=>56,'status'=>1),
array('dna_id'=>58,'status'=>0),
array('dna_id'=>58,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0),
array('dna_id'=>60,'status'=>0),
);
$res = array(
'active'=> array(
'count' => 0,
'ids' => array()
),
'completed' => array(
'count' => 0,
'ids' => array()
),
);
foreach($items as $v) {
if(!in_array($v['dna_id'], $res['active']['ids'])) $res['active']['ids'][] = $v['dna_id'];