Home > Backend Development > PHP Tutorial > 一个有关数组的有关问题(自小弟我感觉有点难)

一个有关数组的有关问题(自小弟我感觉有点难)

WBOY
Release: 2016-06-13 12:42:50
Original
762 people have browsed it

一个有关数组的问题(自我感觉有点难)

本帖最后由 mafeifan 于 2013-07-10 11:02:33 编辑 已知
<br />
$items = array(<br />
    array('dna_id'=>55,'status'=>1),<br />
    array('dna_id'=>55,'status'=>0),<br />
    array('dna_id'=>56,'status'=>1),<br />
    array('dna_id'=>58,'status'=>0),<br />
    array('dna_id'=>58,'status'=>0),<br />
    array('dna_id'=>60,'status'=>0),<br />
    array('dna_id'=>60,'status'=>0),<br />
    array('dna_id'=>60,'status'=>0), <br />
    array('dna_id'=>60,'status'=>0)    <br />
);<br />
Copy after login

欲得到下面的结果,active未完成的记录,个数及id
<br />
array(<br />
    'active'=>array('count'=>3,'ids'=>array('55','58','60')),<br />
    'completed'=>array('count'=>1,'ids'=>array('56'))<br />
);<br />
Copy after login

dna_id可能有多条,当每条dna_id对应的status必须都是1或没有0才放到completed里面,否则放到active里面,通过遍历或者更简单的方法怎么得到上面的结果呢
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template