PHPackages                             tony-sol/flatter - 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. tony-sol/flatter

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

tony-sol/flatter
================

Simple flatter, allows you to flatten and inflate multidimensional arrays

v1.1.1(3y ago)24[1 issues](https://github.com/Tony-Sol/Flatter/issues)[2 PRs](https://github.com/Tony-Sol/Flatter/pulls)MITPHPPHP &gt;=8.1.0CI passing

Since May 29Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Tony-Sol/Flatter)[ Packagist](https://packagist.org/packages/tony-sol/flatter)[ RSS](/packages/tony-sol-flatter/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (7)Used By (0)

Flatter
=======

[](#flatter)

Simple flatter, allows you to flatten and inflate multidimensional arrays
-------------------------------------------------------------------------

[](#simple-flatter-allows-you-to-flatten-and-inflate-multidimensional-arrays)

Usage:

```
$data = [
    'array' => [
        'key' => 'value',
        'inner' => [
            'key' => 1,
            'with_separator' => 2,
        ],
    ],
];

$flattenData = (new \Flatter($data))->flatten();
// $flattenData = [
//     'array_key' => 'value',
//     'array_inner_key' => 1,
//     'array_inner_with_separator' => 2,
// ]

$inflatedData = (new \Flatter($flattenData))->inflate();
// $inflatedData = [
//     'array' => [
//         'key' => 'value',
//         'inner' => [
//             'key' => 1,
//             'with' => [
//                 'separator' => 2,
//             ],
//         ],
//     ],
// ];
```

With custom separator:

```
$flattenData = (new \Flatter($data))->withCompositeKeySeparator('#')->flatten();
// $flattenData = [
//     'array#key' => 'value',
//     'array#inner#key' => 1,
//     'array#inner#with_separator' => 2,
// ]

$inflatedData = (new \Flatter($data))->withCompositeKeySeparator('#')->inflate();
// $inflatedData = [
//     'array' => [
//         'key' => 'value',
//         'inner' => [
//             'key' => 1,
//             'with_separator' => 2,
//         ],
//     ],
// ];
```

With escaping separator in original keys:

```
$flattenData = (new \Flatter($data))->escapingSeparatorInKeys()->flatten();
// $flattenData = [
//     'array_key' => 'value',
//     'array_inner_key' => 1,
//     'array_inner_with\_separator' => 2,
// ]

$inflatedData = (new \Flatter($flattenData))->escapingSeparatorInKeys()->inflate();
// $inflatedData = [
//     'array' => [
//         'key' => 'value',
//         'inner' => [
//             'key' => 1,
//             'with_separator' => 2,
//         ],
//     ],
// ];
```

With closure on keys/values:

```
$flattenData = (new \Flatter($data))
    ->applyClosureToKeys(static function (string $key) { return strtoupper($key); })
    ->applyClosureToValues(static function ($value) { return (string)$value; })
    ->flatten();
// $flattenData = [
//     'ARRAY_KEY' => 'value',
//     'ARRAY_INNER_KEY' => '1',
//     'ARRAY_INNER_WITH_SEPARATOR' => '2',
// ]

$inflatedData = (new \Flatter($flattenData))
    ->applyClosureToKeys(static function (string $key) { return strtolower($key); })
    ->applyClosureToValues(static function ($value) { return "--{$value}--"; })
    ->inflate();
// $inflatedData = [
//     'array' => [
//         'key' => '--value--',
//         'inner' => [
//             'key' => '--1--',
//             'with' => [
//                 'separator' => '--2--',
//             ],
//         ],
//     ],
// ]
```

Disclaimer
----------

[](#disclaimer)

All information and source code are provided AS-IS, without express or implied warranties. Use of the source code or parts of it is at your sole discretion and risk. Citymobil LLC takes reasonable measures to ensure the relevance of the information posted in this repository, but it does not assume responsibility for maintaining or updating this repository or its parts outside the framework established by the company independently and without notifying third parties.

Вся информация и исходный код предоставляются в исходном виде, без явно выраженных или подразумеваемых гарантий. Использование исходного кода или его части осуществляются исключительно по вашему усмотрению и на ваш риск. Компания ООО "Ситимобил" принимает разумные меры для обеспечения актуальности информации, размещенной в данном репозитории, но она не принимает на себя ответственности за поддержку или актуализацию данного репозитория или его частей вне рамок, устанавливаемых компанией самостоятельно и без уведомления третьих лиц.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~83 days

Total

4

Last Release

1292d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab83463a1359bfac1e0ce7467dcd96d0033420a7aa42f6f37355312336037657?d=identicon)[Tony-Sol](/maintainers/Tony-Sol)

---

Top Contributors

[![tony-sol](https://avatars.githubusercontent.com/u/33671815?v=4)](https://github.com/tony-sol "tony-sol (4 commits)")[![inshopper](https://avatars.githubusercontent.com/u/33682098?v=4)](https://github.com/inshopper "inshopper (1 commits)")

---

Tags

arraysflatternphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tony-sol-flatter/health.svg)

```
[![Health](https://phpackages.com/badges/tony-sol-flatter/health.svg)](https://phpackages.com/packages/tony-sol-flatter)
```

###  Alternatives

[unleash/symfony-client-bundle

37543.6k](/packages/unleash-symfony-client-bundle)

PHPackages © 2026

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