src/ArrayUtils.php
public static function flatten(array $array, $separator = '.', $prefix = '')
    {
        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $newPrefix = empty($prefix) ? $key : "$prefix.$key";
                $result = array_merge($result, self::flatten($value, $separator, $newPrefix));
            } else {
                $newKey = empty($prefix) ? $key : "$prefix.$key";
                $result[$newKey] = $value;
            }
        }

        return $result;
    }
public static function flatten(array $array, $separator = '.', $prefix = '')
    {
        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $newPrefix = empty($prefix) ? $key : "$prefix.$key";
                $result = array_merge($result, self::flatten($value, $separator, $newPrefix));
            } else {
                $newKey = empty($prefix) ? $key : "$prefix.$key";
                $result[$newKey] = $value;
            }
        }

        return $result;
    }
public static function flatten ( array $ array , $ separator = '.' , $ prefix = '' ) { $ result = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ newPrefix = empty ( $ prefix ) ? $ key : "$prefix.$key" ; $ result = array_merge ( $ result , self :: flatten ( $ value , $ separator , $ newPrefix ) ) ; } else { $ newKey = empty ( $ prefix ) ? $ key : "$prefix.$key" ; $ result [ $ newKey ] = $ value ; } } return $ result ; }
Flattens a deep array to a single dimension.

@param array  $array      Array to flatten.
@param string $separator  Separator used to divide key values.
@param string $prefix     Initial key prefix. Empty by default.

@throws InvalidArgumentException if a non-array value is given
Flattens a deep array to a single dimension .