php 无限极分类
//无限极分类 展示 function getree($arr,$pid,$step){ global $tree; foreach ($arr as $key => $value) { if ($value['pid']==$pid) { $temp=str_repeat('└―', $step); $value['name']=$temp.$value['name']; $tree[]=$value; getree($arr,$value['cid'],$step+1); } } return $tree; } //子集 child function getTree1($arr, $pid,$level){ $tree = ''; foreach($arr as $k => $v){ $v['level']=$level; if($v['pid'] == $pid){//父亲找到儿子 $v['child'] = getTree1($arr, $v['cid'],$level+1); $tree[] = $v; //unset($data[$k]); } } return $tree; }