/** * 递归循环分类 */ private function foreachd($arr, $id = 0, $level = 0) { if (!$arr) return $arr; $list = []; foreach ($arr as $k=>$v){ if ($v['parent_id'] == $id) { $v['level'] = $level; $v['children'] = $this->foreachd($arr, $v['id'], $level+1); $list[] = $v; } } return $list; }
09-07
585
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-10
1118
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)