我的文章
php 递归
public function loop($array,$pid = 0){ $data = array(); foreach ($array as $k=>$v){ if ($v['pid'] == $pid){ $child = $this->loop($array,$v["id"]); $v["child"] = $child?:[]; $data[] = $v; } } return $data; }
林外听秋风