PHPackages                             hhpp33/tree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hhpp33/tree

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hhpp33/tree
===========

tree data 使用递归生成树形数据，简单实用

06PHP

Since Sep 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/hhpp33/Tree)[ Packagist](https://packagist.org/packages/hhpp33/tree)[ RSS](/packages/hhpp33-tree/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

php递归无限级树形数据
============

[](#php递归无限级树形数据)

使用使用方法
------

[](#使用使用方法)

```
use  Caihui\Tree\Tree;
require __DIR__ . '/../vendor/autoload.php';
```

#### 全部数据数组

[](#全部数据数组)

```
$data = include __DIR__."/data.php";
```

#### 设置主键、parent标识名称 字节点名称

[](#设置主键parent标识名称-字节点名称)

```
Tree::setConfig($primary = '', $parentId = '', $child = '');
```

#### 生成tree data

[](#生成tree-data)

```
Tree::makeTree($data);
```

运行结果

```
Array
(
    [0] = Array
   (
      [id] = 1
       [city] = 中国
       [parent_id] = 0
        [child] = Array
         (
                 [0] = Array
                      (
                             [id] = 2
                            [city] = 北京
                             [parent_id] = 1
                             [child] = Array
                                (
                                 [0] = Array
                                         (
                                             [id] = 3
                                            [city] = 北京市
                                            [parent_id] = 2
                                            [child] = Array
                                                (
                                                   [0] = Array
                                                       (
                                                            [id] = 4
                                                            [city] = 东城区
                                                            [parent_id] = 3
                                                        )

                                                )

                                        )

                                )

                        )

                    [1] = Array
                        (
                            [id] = 11
                            [city] = 上海
                            [parent_id] = 1
                            [child] = Array
                                (
                                    [0] = Array
                                        (
                                            [id] = 12
                                            [city] = 上海市
                                            [parent_id] = 11
                                        )

                                )

                        )

                )

        )

)
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5828750?v=4)[hhpp33](/maintainers/hhpp33)[@hhpp33](https://github.com/hhpp33)

---

Top Contributors

[![hhpp33](https://avatars.githubusercontent.com/u/5828750?v=4)](https://github.com/hhpp33 "hhpp33 (2 commits)")

### Embed Badge

![Health badge](/badges/hhpp33-tree/health.svg)

```
[![Health](https://phpackages.com/badges/hhpp33-tree/health.svg)](https://phpackages.com/packages/hhpp33-tree)
```

###  Alternatives

[grrr-amsterdam/garp-functional

Utility library embracing functional programming paradigms.

32117.6k5](/packages/grrr-amsterdam-garp-functional)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
