thinkphp5資料的無限分類

遠方*發表於2020-10-06
public function getHtmlList(&$result = [], $pid = 0, $prefx = '')
    {
        $data = $this->where(['is_delete'=> 0])->select()->toarray();

        foreach ($data as $value) {
            if ($value['parent_id'] == $pid) {
                $value['name'] = $prefx.$value['name'];
                $result[] = $value;
                $this->getHtmlList($result,$value['id'],$prefx.'|--');
            }
        }

        return $result;
    }

相關文章