慕粉5283508
2018-04-03 14:57
private $tree = []; public function diggn($pid=0,$span = 0){ $span += 2; $sql = "SELECT * from `car_deepclassify` where `pid` = {$pid} order by `createtime` desc"; $results = $this->db->query($sql)->result_array(); // var_dump($_POST);exit; foreach ($results as $key => $result) { // $result['catename'] = $send = $this->db->where('id',$result['id'])->get('car_deepclassify')->row_array(); $send['catename'] = str_repeat(' ',$span).'|--'.$result['catename']; $this->tree[] = $send; $this->diggn($result['id'],$span); } } public function diguiceshi(){ $this->diggn(); echo '<pre>'; print_r($this->tree); echo '</pre>'; }
像老师那样为啥实现不了 ,只能这样实现呢???(框架ci)
在框架里面只能写入方法里再调用啊!讲师那个是基本的php文件操作格式
class>public>function>obj
PHP无限级分类技术
30076 学习 · 83 问题
相似问题