public static function flatten(array $array, string $separator = null, string $prepend = ''): array
    {
        $flattened = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $flattened = array_merge($flattened, static::flatten($value, $separator, $prepend . $key . $separator));
            } else {
                $flattened[$prepend . $key] = $value;
            }
        }

        return $flattened;
    }
public static function flatten(array $array, string $separator = null, string $prepend = ''): array
    {
        $flattened = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $flattened = array_merge($flattened, static::flatten($value, $separator, $prepend . $key . $separator));
            } else {
                $flattened[$prepend . $key] = $value;
            }
        }

        return $flattened;
    }
public static function flatten ( array $ array , string $ separator = null , string $ prepend = '' ) : array { $ flattened = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ flattened = array_merge ( $ flattened , static :: flatten ( $ value , $ separator , $ prepend . $ key . $ separator ) ) ; } else { $ flattened [ $ prepend . $ key ] = $ value ; } } return $ flattened ; }
Flatten a nested array to a separated key.

@param array       $array
@param string|null $separator
@param string      $prepend

@return array
Flatten a nested array to a separated key .