Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

List.flat

flat($depth = 1)

Description

Convert a mult-dimensional List into a single List with values from all of its sub-Lists.

depth: how many levels of sub-Lists should be flattened.

$mdList = [1, 2, [3, 4]];
$mdList.flat();
//= [1, 2, 3, 4]

$mdList = [1, 2, [3, 4, [5, 6]]];
$mdList.flat();
//= [1, 2, 3, 4, [5, 6]]

$mdList = [1, 2, [3, 4, [5, 6]]];
$mdList.flat(2);
//= [1, 2, 3, 4, 5, 6]

See Also