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

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

yarri/array-flatten
===================

Convert a multi-dimensional array into a single-dimensional array

v0.2(2y ago)15.1k↑95%MITPHPPHP &gt;=5.6CI passing

Since Apr 26Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/yarri/ArrayFlatten)[ Packagist](https://packagist.org/packages/yarri/array-flatten)[ Docs](https://github.com/yarri/ArrayFlatten)[ RSS](/packages/yarri-array-flatten/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

ArrayFlatten
============

[](#arrayflatten)

[![Tests](https://github.com/yarri/ArrayFlatten/actions/workflows/tests.yml/badge.svg)](https://github.com/yarri/ArrayFlatten/actions/workflows/tests.yml)

Convert a multi-dimensional array into a single-dimensional array

Function signature
------------------

[](#function-signature)

```
array_flatten(array $array, bool $preserve_keys = false): array

```

#### Parameters

[](#parameters)

**array**

The multi-dimensional array.

**preserve\_keys**

Whether or not to preserve keys in the output array.

#### Return value

[](#return-value)

The function array\_flatten returns single-dimensional array or false if no array is given as the parameter $array.

Usage
-----

[](#usage)

```
$ar = ["a", ["b", "c"], [["d",["e","f"]]]];
array_flatten($ar); // ["a","b","c","d","e","f"]

$ar = ["x" => "a", "y" => ["z" => "b", "c"]];
array_flatten($ar); // ["a", "b", "c"]
array_flatten($ar,false); // ["a", "b", "c"]
array_flatten($ar,true); // ["x" => "a", "z" => "b", 0 => "c"]

// !! duplicit key "x"
$ar = ["x" => "a", "y" => ["z" => "b", "x" => "c"]];
array_flatten($ar); // ["a", "b", "c"]
array_flatten($ar,true); // ["x" => "c", "z" => "b"]

```

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

[](#installation)

Just use the Composer:

```
composer require yarri/array-flatten

```

License
-------

[](#license)

ArrayFlatten is free software distributed [under the terms of the MIT license](http://www.opensource.org/licenses/mit-license)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance58

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 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 ~16 days

Total

2

Last Release

736d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6304dffbd91d7a978f98632b0e4e30d662dcdb691daadb1388a58984e98faf5c?d=identicon)[yarri](/maintainers/yarri)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[tareq1988/wp-php-cs-fixer

WordPress rules for php-cs-fixer

3567.8k6](/packages/tareq1988-wp-php-cs-fixer)[liopic/korean-romanizer

Library to romanize Korean in UTF-8 format

18162.4k](/packages/liopic-korean-romanizer)

PHPackages © 2026

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