无限极分类

<?php
function getTree($list,$parent_id=0,$level=0) {
 static $tree = array();
 foreach($list as $row) {
  //父类ID=$parent_id
  if($row['c_parent_id']==$parent_id) {
   $row['level'] = $level;
   $tree[] = $row;
   getTree($list, $row['c_id'], $level + 1);
  }
 }
 return $tree;
 
  
}
?>

你可能感兴趣的:(无限极分类)