PHPackages                             cable8mm/array-flatten - 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. cable8mm/array-flatten

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

cable8mm/array-flatten
======================

Flatten a multi-dimensional array in PHP.

v1.1.0(6d ago)037.7k↑836.7%2MITPHPPHP ^8.0.2CI passing

Since Mar 1Pushed 6d ago1 watchersCompare

[ Source](https://github.com/cable8mm/array-flatten)[ Packagist](https://packagist.org/packages/cable8mm/array-flatten)[ RSS](/packages/cable8mm-array-flatten/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (2)

Array Flatten
=============

[](#array-flatten)

[![code-style](https://github.com/cable8mm/array-flatten/actions/workflows/code-style.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/code-style.yml)[![run-tests](https://github.com/cable8mm/array-flatten/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/run-tests.yml)[![Packagist Version](https://camo.githubusercontent.com/da70446767e570b7c1695d5fa0a3d36e894ec56269bc2483ad4d13320c8c927c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361626c65386d6d2f61727261792d666c617474656e)](https://camo.githubusercontent.com/da70446767e570b7c1695d5fa0a3d36e894ec56269bc2483ad4d13320c8c927c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361626c65386d6d2f61727261792d666c617474656e)[![Packagist Downloads](https://camo.githubusercontent.com/3cad7f615413976204154dc87f25c406ecd01d6187f5fcc1198b4370b786e855/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6361626c65386d6d2f61727261792d666c617474656e)](https://camo.githubusercontent.com/3cad7f615413976204154dc87f25c406ecd01d6187f5fcc1198b4370b786e855/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6361626c65386d6d2f61727261792d666c617474656e)[![Packagist Dependency Version](https://camo.githubusercontent.com/330d75bb75afdf1e66d0890041971ad824e7a8a5fa1234b0f5f5e162cb145aa2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f61727261792d666c617474656e2f706870)](https://camo.githubusercontent.com/330d75bb75afdf1e66d0890041971ad824e7a8a5fa1234b0f5f5e162cb145aa2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6361626c65386d6d2f61727261792d666c617474656e2f706870)[![Packagist Stars](https://camo.githubusercontent.com/6bdfbca205009d47413dd012c6bd7dc157fa7468653f0ec76d9290e7b45e80e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6361626c65386d6d2f61727261792d666c617474656e)](https://camo.githubusercontent.com/6bdfbca205009d47413dd012c6bd7dc157fa7468653f0ec76d9290e7b45e80e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6361626c65386d6d2f61727261792d666c617474656e)[![Packagist License](https://camo.githubusercontent.com/c6776b5a7fb4ec83ba166b4b9a46d9d8f728f2cbd679e4c58e8f0264d85e171a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6361626c65386d6d2f61727261792d666c617474656e)](https://camo.githubusercontent.com/c6776b5a7fb4ec83ba166b4b9a46d9d8f728f2cbd679e4c58e8f0264d85e171a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6361626c65386d6d2f61727261792d666c617474656e)

Normalize nested arrays.

`array_flatten()` returns a flat list from nested arrays and removes duplicate scalar values using strict comparison. For more information, please visit .

Why
---

[](#why)

To normalize nested arrays into a flat list while preserving first-seen order and strict uniqueness.

Installation
------------

[](#installation)

```
composer require cable8mm/array-flatten
```

Usage
-----

[](#usage)

```
use function Cable8mm\ArrayFlatten\array_flatten;

array_flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]);
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
```

Behavior
--------

[](#behavior)

- Preserves first-seen order.
- Applies strict deduplication to scalar values.
- Traverses nested arrays at any depth.

License
-------

[](#license)

The Array Flatten is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance98

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~424 days

Total

3

Last Release

6d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.1.0PHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c910c874a0263a18f9f976273054cd45faa3ffbcba7891992f4ab52d0656dd93?d=identicon)[Sam Lee](/maintainers/Sam%20Lee)

---

Top Contributors

[![cable8mm](https://avatars.githubusercontent.com/u/2672043?v=4)](https://github.com/cable8mm "cable8mm (9 commits)")

---

Tags

arrayarray-flattenflattenphp

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cable8mm-array-flatten/health.svg)

```
[![Health](https://phpackages.com/badges/cable8mm-array-flatten/health.svg)](https://phpackages.com/packages/cable8mm-array-flatten)
```

###  Alternatives

[mohamedsabil83/laravel-hijrian

Hijri-Gregorian date converter for Laravel

1322.4k](/packages/mohamedsabil83-laravel-hijrian)[milenmk/laravel-locations

Add Countries, Cities, Areas, Languages and Currencies models to your Laravel application

471.2k](/packages/milenmk-laravel-locations)

PHPackages © 2026

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