aviator / array-fold
Fold all elements of a multidimentional array down to a single level.
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
pkg:composer/aviator/array-fold
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).