if (!function_exists('get_tree_list')) {
function get_tree_list($list)
{
//将每条数据中的id值作为其下标
$temp = [];
foreach ($list as $v) {
$v['son'] = [];
$temp[$v['id']] = $v;
}
//获取分类树
foreach ($temp as $k => $v) {
$temp[$v['pid']]['son'][] =& $temp[$v['id']];
}
return isset($temp[0]['son']) ? $temp[0]['son'] : [];
}
}
tp6实现父子级树状结构封装方法
于 2022-03-04 13:44:42 首次发布