Normalize nested arrays.
array_flatten() returns a flat list from nested arrays and removes duplicate scalar values using strict comparison. For more information, please visit https://www.palgle.com/array-flatten/.
To normalize nested arrays into a flat list while preserving first-seen order and strict uniqueness.
composer require cable8mm/array-flattenuse function Cable8mm\ArrayFlatten\array_flatten;
array_flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]);
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]- Preserves first-seen order.
- Applies strict deduplication to scalar values.
- Traverses nested arrays at any depth.
The Array Flatten is open-sourced software licensed under the MIT license.