PHPackages                             knowcup/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. knowcup/tree

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

knowcup/tree
============

07PHP

Since Apr 13Pushed 8y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

tree
====

[](#tree)

数组转为树状结构，支持树状嵌套、树状列表 php版本 &gt;= 7.0

数组:

```
$array = [
    [ 'id' => 1, 'parent_id' => null, 'name' => '第一级 One' ],
    [ 'id' => 2, 'parent_id' => null, 'name' => '第一级 Two' ],
    [ 'id' => 3, 'parent_id' => null, 'name' => '第一级 Three' ],
    [ 'id' => 4, 'parent_id' => 1, 'name' => '第二级 One' ],
    [ 'id' => 5, 'parent_id' => 1, 'name' => '第二级 Two' ],
    [ 'id' => 6, 'parent_id' => 1, 'name' => '第二级 Three' ],
    [ 'id' => 7, 'parent_id' => 3, 'name' => '第二级 Four' ],
    [ 'id' => 8, 'parent_id' => 3, 'name' => '第二级 Five' ],
    [ 'id' => 9, 'parent_id' => 5, 'name' => '第三级 One' ],
    [ 'id' => 10, 'parent_id' => 5, 'name' => '第三级 Two' ]
];
```

转为树状列表（平行）：

```
\knowcup\tree\Tree::listTreeArr($array);
```

转为树状列表（嵌套）：

```
\knowcup\tree\Tree::nestTreeArr($array);
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

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/35452005?v=4)[knowcup](/maintainers/knowcup)[@knowcup](https://github.com/knowcup)

---

Top Contributors

[![knowcup](https://avatars.githubusercontent.com/u/35452005?v=4)](https://github.com/knowcup "knowcup (12 commits)")

### Embed Badge

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

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

PHPackages © 2026

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