递归 /** * 初始化 $treeList * @var array */ static public $treeList = array(); /** * 递归处理 * @param $data * @param null $parent * @param int $level 层次 * @return array */ protected function limitTree($data, $parent = null, $l
/** * 初始化 $treeList * @var array */ static public $treeList = array(); /** * 递归处理 * @param $data * @param null $parent * @param int $level 层次 * @return array */ protected function limitTree($data, $parent = null, $level = 1) { foreach ($data as $key => &$vo) { if ($vo['parent'] == $parent) { $vo['level'] = $level; self::$treeList[] = $vo; unset($data[$key]); self::limitTree($data, $vo['id'], $level + 1); } } return self::$treeList; }