主页 > php易尔灵网络科技

php中无限分类

153 2024-03-09 16:25

function buildTree(array $elements, $parentId = 0) { $branch = array(); foreach ($elements as $element) { if ($element['parent_id'] == $parentId) { $children = buildTree($elements, $element['id']); if ($children) { $element['children'] = $children; } $branch[] = $element; } } return $branch; } $nestedCategories = buildTree($categories);
顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
点击我更换图片

热点提要

网站地图 (共30个专题151926篇文章)

返回首页