最後活躍 1714735592

stuzer05 已修改 1714735592. 還原成這個修訂版本

1 file changed, 17 insertions

index.php(檔案已創建)

@@ -0,0 +1,17 @@
1 + function buildTree(array $elements, $parentId = 0) {
2 + $branch = array();
3 +
4 + foreach ($elements as $element) {
5 + if ($element['parent_id'] == $parentId) {
6 + $children = buildTree($elements, $element['id']);
7 + if ($children) {
8 + $element['children'] = $children;
9 + }
10 + $branch[] = $element;
11 + }
12 + }
13 +
14 + return $branch;
15 + }
16 +
17 + $tree = buildTree($rows);
上一頁 下一頁