无限极分类php
public function Infinite(){ $data=$this->SortRepositorie->sate();//查出的分类数据 /* * 商品分类数据 */ $array = $this->getTree($data); // print_r($array);die; return $array; } //无极限分类 public function getTree($data,$pid=0){ $arr=array(); foreach($data as $key=>$value){ if($value['pid']==$pid){ $arr[$key]=$value; $arr[$key]['chid']=$this->getTree($data,$value['id']); } } return $arr; }