PHPackages                             chastephp/array2tree - 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. chastephp/array2tree

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

chastephp/array2tree
====================

a simple php function to convert array to tree

1.0.2(3y ago)240MITPHP

Since Apr 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/chastephp/array2tree)[ Packagist](https://packagist.org/packages/chastephp/array2tree)[ RSS](/packages/chastephp-array2tree/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

array2tree
==========

[](#array2tree)

a simple php function that convert array to tree

Install
-------

[](#install)

```
composer require chastephp/array2tree
```

Usage
-----

[](#usage)

```
$arr = [
    ['id' => 1, 'name' => '11', 'parent_id' => 0],
    ['id' => 2, 'name' => '22', 'parent_id' => 1],
    ['id' => 3, 'name' => '33', 'parent_id' => 2],
    ['id' => 4, 'name' => '44', 'parent_id' => 2],
];

var_dump(array2tree($arr, 'id', 'parent_id', 'children'));
```

```
array (
  0 =>
  array (
    'id' => 1,
    'name' => '11',
    'parent_id' => 0,
    'children' =>
    array (
      0 =>
      array (
        'id' => 2,
        'name' => '22',
        'parent_id' => 1,
        'children' =>
        array (
          0 =>
          array (
            'id' => 3,
            'name' => '33',
            'parent_id' => 2,
            'children' =>
            array (
            ),
          ),
        ),
      ),
    ),
  ),
)

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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.

###  Release Activity

Cadence

Every ~386 days

Total

3

Last Release

1455d ago

### Community

Maintainers

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

---

Top Contributors

[![widdy](https://avatars.githubusercontent.com/u/1439752?v=4)](https://github.com/widdy "widdy (7 commits)")[![chastephp](https://avatars.githubusercontent.com/u/24683435?v=4)](https://github.com/chastephp "chastephp (3 commits)")

---

Tags

array2treearraytotree

### Embed Badge

![Health badge](/badges/chastephp-array2tree/health.svg)

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

###  Alternatives

[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)

PHPackages © 2026

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