PHPackages                             byjoby/flatrr - 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. byjoby/flatrr

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

byjoby/flatrr
=============

A library for working with multi-dimensional arrays through flattened keys

v1.5.3(2w ago)07.5k3MITPHPPHP &gt;=8.1CI passing

Since Sep 14Pushed 2w ago1 watchersCompare

[ Source](https://github.com/joby-lol/flatrr)[ Packagist](https://packagist.org/packages/byjoby/flatrr)[ RSS](/packages/byjoby-flatrr/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (8)Dependencies (12)Versions (19)Used By (3)

Flatrr
======

[](#flatrr)

What Flatrr does
----------------

[](#what-flatrr-does)

Flatrr is a utility library for accessing arrays via flattened key names. So, for example, rather than using `$arr['foo']['bar']` you could use `$arr['foo.bar']`. Mostly this is useful if you want to use string building to make the keys you're going to use to access an array.

It should be noted that because of the way arrays and references work, this is not going to work *exactly* the same way as a native array in all cases. There are actually countless tiny caveats, and with that in mind you should generally stick to using this library as it is documented. Using undocumented features is exceptionally unpredictable due to the nature of this tool, and things may work radically different under the hood in the future.

FlatArray
---------

[](#flatarray)

The main FlatArray class is very simple. It only implements \\Array and \\Iterator. With it you can make arrays, merge values into them, and retrieve parts of the array via flattened keys.

### Constructing and getting values

[](#constructing-and-getting-values)

```
// Instantiating FlatArrays can be done by passing them an array
// Keys in the initial array will be unflattened, for example the following
// yields a FlatArray containing ['foo'=>'bar','bar'=>['baz'=>'a','buz'=>'u']]
$f = new \Flatrr\FlatArray([
  'foo' => 'bar',
  'bar.baz' => 'a',
  'bar.buz' => 'u'
]);
```

You can then access the values of the array like a normal array, through the `get()` method, or by flattened keys.

```
// All of the following are equal to 'a'
$f['bar']['baz'];
$f['bar.baz'];
$f->get('bar.baz');
```

### Setting values

[](#setting-values)

Values can be set through either flattened keys or the `set()` method. Setting values like a normal multi-dimensional array won't work beyond the first layer, and it shouldn't be done.

```
// Both of these work
$f['foo.bar'] = 'baz';
$f->set('foo.bar','baz');
// This does NOT work
$f['foo']['bar'] = 'baz';
```

SelfReferencingFlatArray
------------------------

[](#selfreferencingflatarray)

SelfReferencingFlatArray is a class that does everything FlatArray does, but also allows strings within the array to reference other fields within the array, and include them as strings. For example:

```
$f = new \Flatrr\SelfReferencingFlatArray([
  'foo.bar' => 'baz',
  'foo.baz' => '${foo.bar}'
]);
// foo.baz will now always return the value of foo.bar
// echoes 'baz'
echo $f['foo.baz'];
// You can also get the "raw" value of a field using get()
// echoes '${foo.bar}'
echo $f->get('foo.baz');
// Variables can also be used as part of other strings
$f['a'] = 'foo.bar is: ${foo.bar}';
// echoes 'foo.bar is: baz'
echo $f['a'];
// Variables are resolved recursively
$f['b'] = 'foo.baz is: ${foo.baz}';
// echoes 'foo.baz is: baz'
echo $f['b'];
```

Config
------

[](#config)

Config does the same things as SelfReferencingFlatArray, but adds methods for reading INI, JSON, and YAML files. It also provides methods for extracting its contents as JSON and YAML.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance97

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

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

Recently: every ~322 days

Total

18

Last Release

16d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v1.5.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4e606aa41ebfd7d82c365c6dc4ec158fb1b0bfff5f8dcbfad4ab53e3092e6a6?d=identicon)[jobyone](/maintainers/jobyone)

---

Top Contributors

[![joby-lol](https://avatars.githubusercontent.com/u/856610?v=4)](https://github.com/joby-lol "joby-lol (45 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/byjoby-flatrr/health.svg)

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

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49617.1k](/packages/blackfire-player)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

43785.5k4](/packages/lullabot-drainpipe)[altis/local-server

Local Server module for Altis

18221.6k3](/packages/altis-local-server)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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