public static function flatten(array $subjectArray, $depth = INF)
    {
        $flattenArray = [];

        foreach ($subjectArray as $value) {
            if (!is_array($value)) {
                $flattenArray[] = $value;
            } elseif ($depth === 1) {
                $flattenArray = array_merge($flattenArray, array_values($value));
            } else {
                $flattenArray = array_merge($flattenArray, static::flatten($value, $depth - 1));
            }
        }

        return $flattenArray;
    }
public static function flatten(array $subjectArray, $depth = INF)
    {
        $flattenArray = [];

        foreach ($subjectArray as $value) {
            if (!is_array($value)) {
                $flattenArray[] = $value;
            } elseif ($depth === 1) {
                $flattenArray = array_merge($flattenArray, array_values($value));
            } else {
                $flattenArray = array_merge($flattenArray, static::flatten($value, $depth - 1));
            }
        }

        return $flattenArray;
    }
public static function flatten ( array $ subjectArray , $ depth = INF ) { $ flattenArray = [ ] ; foreach ( $ subjectArray as $ value ) { if ( ! is_array ( $ value ) ) { $ flattenArray [ ] = $ value ; } elseif ( $ depth === 1 ) { $ flattenArray = array_merge ( $ flattenArray , array_values ( $ value ) ) ; } else { $ flattenArray = array_merge ( $ flattenArray , static :: flatten ( $ value , $ depth - 1 ) ) ; } } return $ flattenArray ; }
Flatten a multi-dimensional array into a single level.  Keys are not preserved.

@since 3.1.6

@param  array $subjectArray The subject array to work on.
@param  int $depth (Optional) The depth to flatten. Default is INF (infinite), meaning all levels.

@return array
Flatten a multi - dimensional array into a single level . Keys are not preserved .