PHP数组无限分级数据的层级化处理代码(2)

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));

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/e08f837b629316aaa1c87affe8422f67.html