src/Collection/ArrayCollection.php
protected static function flattenArray(array $array, int $depth = PHP_INT_MAX): array
    {
        $items = [];

        foreach ($array as $item) {
            if ($item instanceof self) {
                $item = $item->all();
            }

            if (is_array($item)) {
                if ($depth === 1) {
                    $items = array_merge($items, $item);
                    continue;
                }
                $items = array_merge($items, static::flattenArray($item, $depth - 1));
                continue;
            }

            $items[] = $item;
        }

        return $items;
    }
protected static function flattenArray(array $array, int $depth = PHP_INT_MAX): array
    {
        $items = [];

        foreach ($array as $item) {
            if ($item instanceof self) {
                $item = $item->all();
            }

            if (is_array($item)) {
                if ($depth === 1) {
                    $items = array_merge($items, $item);
                    continue;
                }
                $items = array_merge($items, static::flattenArray($item, $depth - 1));
                continue;
            }

            $items[] = $item;
        }

        return $items;
    }
protected static function flattenArray ( array $ array , int $ depth = PHP_INT_MAX ) : array { $ items = [ ] ; foreach ( $ array as $ item ) { if ( $ item instanceof self ) { $ item = $ item -> all ( ) ; } if ( is_array ( $ item ) ) { if ( $ depth === 1 ) { $ items = array_merge ( $ items , $ item ) ; continue ; } $ items = array_merge ( $ items , static :: flattenArray ( $ item , $ depth - 1 ) ) ; continue ; } $ items [ ] = $ item ; } return $ items ; }
Flattens a multi-dimensional array into a single level

@param array $array The array
@param int   $depth The depth

@return array
Flattens a multi - dimensional array into a single level