src/Support/Arr.php
/**
	 * Flatten a multi-dimensional array into a single level.
	 *
	 * @param array $array
	 * @param int $depth
	 * @return array
	 */
Flatten a multi-dimensional array into a single level.
Flatten a multi - dimensional array into a single level .
public static function flatten($array, $depth = INF) {
		return array_reduce($array, function ($result, $item) use ($depth) {
			if (!is_array($item)) {
				return array_merge($result, [$item]);
			}
			else if ($depth === 1) {
				return array_merge($result, array_values($item));
			}
			else {
				return array_merge($result, static::flatten($item, $depth - 1));
			}
		}, array());
	}
public static function flatten ( $ array , $ depth = INF ) { return array_reduce ( $ array , function ( $ result , $ item ) use ( $ depth ) { if ( ! is_array ( $ item ) ) { return array_merge ( $ result , [ $ item ] ) ; } else if ( $ depth === 1 ) { return array_merge ( $ result , array_values ( $ item ) ) ; } else { return array_merge ( $ result , static :: flatten ( $ item , $ depth - 1 ) ) ; } } , array ( ) ) ; }
Flatten a multi-dimensional array into a single level.
Flatten a multi - dimensional array into a single level .