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.
Via Composer:
composer require aviator/array-fold
Via Composer:
composer test
$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',
]
*/
This package is licensed with the MIT License (MIT).