aviator / array-fold
This package is abandoned and no longer maintained.
No replacement package was suggested.
Fold all elements of a multidimentional array down to a single level.
0.1.0
2017-11-25 20:19 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- larapack/dd: ^1.1
- phpunit/phpunit: ~6.4.0
This package is auto-updated.
Last update: 2024-04-21 19:55:54 UTC
README
Overview
array_fold()
takes an multidimensional array of any depth and recursively folds each level into the previous, flattening it to a single level.
By default it preserves (and overwrites) keys, though this can be disabled with the optional second parameter.
Installation
Via Composer:
composer require aviator/array-fold
Testing
Via Composer:
composer test
Usage
$array = [ 'level1' [ 'some' => 'value', 'someOther' => 'value', 'level2' => [ 'someOther' => 'value' ] ] ]; // Using keys echo array_fold($array); /* [ 'some' => 'value', 'someOther' => 'value', ] */ // Ignoring keys echo array_fold($array, false); /* [ 'value', 'value', 'value', ] */
Other
License
This package is licensed with the MIT License (MIT).