function _findChildren($list, $p_id){ //数据层级化,
$r = array();
foreach($list as $id=>$item){
if($item['parent_id'] == $p_id) {
$length = count($r);
$r[$length] = $item;
if($t = $this->_findChildren($list, $item['id']) ){
$r[$length]['children'] = $t;
}
}
}
return $r;
}
print_r(_findChildren($mylist, 0));
您可能感兴趣的文章: