PHPackages                             ishworkh/multi-level-array-iterator - 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. ishworkh/multi-level-array-iterator

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

ishworkh/multi-level-array-iterator
===================================

Provides a way to loop through nested arrays with any depth

v2.0.0(9y ago)07.4k↓33.3%MITPHPPHP &gt;=7.0

Since Dec 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ishworkh/php-multi-level-array-iterator)[ Packagist](https://packagist.org/packages/ishworkh/multi-level-array-iterator)[ RSS](/packages/ishworkh-multi-level-array-iterator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (7)Used By (0)

(PHP) Multi Level Array Iterator
================================

[](#php-multi-level-array-iterator)

There are times when there is a need to iterate over an array being unknown about the level of nested array it contains. Multi Level Array Iterator lets u do that. This functionality supports associative array and is properly tested.

Basic Usage
-----------

[](#basic-usage)

```
$array = [
    1,
    2,
    [
        3,
        4
    ],
    [
        5,
        6,
        [
            7,
            8
        ]
    ],
    [
        9,
        [
            [
                10
            ]
        ],
        11
    ]
];

foreach(\ArrayIterator\ArrayIteratorFacade::iterate($array) as $key => $ArrayItem)
{
    echo $key . ' - ' . $ArrayItem->getValue() . "\n";
}

Result:
    0 - 1
    1 - 2
    0 - 3
    1 - 4
    0 - 5
    1 - 6
    0 - 7
    1 - 8
    0 - 9
    0 - 10
    2 - 11
```

`\ArrayIterator\ArrayIteratorFacade::iterate($array)` returns a generator of `ArrayElementInterface`.

`ArrayElementInterface` provides

1. getValue():mixed
2. getKeyHierarchy():KeyHierarchyInterface
    - getParentKey(int $parentLevel): string
    - getHierarchyLevel(): int

New instance of `\ArrayIterator\Iterator\ArrayIterator` can be created with `\ArrayIterator\ArrayIteratorFactory` which is accessible through `\ArrayIterator\ArrayIteratorLocator`. Both the facade or locator way can be used to get an instance of ArrayIterator.

It includes special support for laravel framework. For its integration with Laravel's dependency injection container `\ArrayIterator\ArrayIteratorServiceProvider` is available which can be included in the lists of service providers in `config/app.php`. After this, type hinting `\ArrayIterator\ArrayIteratorFactory` anywhere inside laravel app will resolve into `\ArrayIterator\ArrayIteratorFactory` properly.

Note: - For debugging purpose, echoing `KeyHierarchyInterface` prints out string representation of keys hierarchy starting from root array separated by '-'. - Upgraded to php7

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~14 days

Total

6

Last Release

3375d ago

Major Versions

v1.3.0 → v2.0.02017-02-18

PHP version history (3 changes)v1.2.0PHP ^5.5 || ^7.0

v1.2.1PHP &gt;=5.5

v2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3979c17972ec78de21422079dfb3832b9ee5e3301255864ef7a70191526b34c1?d=identicon)[Ishworkh](/maintainers/Ishworkh)

---

Top Contributors

[![ishworkh](https://avatars.githubusercontent.com/u/2223527?v=4)](https://github.com/ishworkh "ishworkh (1 commits)")

---

Tags

phplaravelarrayiteratormulti levelrecursive

### Embed Badge

![Health badge](/badges/ishworkh-multi-level-array-iterator/health.svg)

```
[![Health](https://phpackages.com/badges/ishworkh-multi-level-array-iterator/health.svg)](https://phpackages.com/packages/ishworkh-multi-level-array-iterator)
```

###  Alternatives

[ginq/ginq

LINQ to Object inspired DSL for PHP

192257.5k3](/packages/ginq-ginq)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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