public static function toHeaderLine($headers, $toString = false)
    {
        $headerArray = [];

        foreach ($headers as $key => $value) {
            $value = is_array($value) ? implode(',', $value) : $value;

            $headerArray[] = static::normalizeHeaderName($key) . ': ' . $value;
        }

        if ($toString) {
            $headerArray = implode($headerArray, "\r\n");
        }

        return $headerArray;
    }
public static function toHeaderLine($headers, $toString = false)
    {
        $headerArray = [];

        foreach ($headers as $key => $value) {
            $value = is_array($value) ? implode(',', $value) : $value;

            $headerArray[] = static::normalizeHeaderName($key) . ': ' . $value;
        }

        if ($toString) {
            $headerArray = implode($headerArray, "\r\n");
        }

        return $headerArray;
    }
public static function toHeaderLine ( $ headers , $ toString = false ) { $ headerArray = [ ] ; foreach ( $ headers as $ key => $ value ) { $ value = is_array ( $ value ) ? implode ( ',' , $ value ) : $ value ; $ headerArray [ ] = static :: normalizeHeaderName ( $ key ) . ': ' . $ value ; } if ( $ toString ) { $ headerArray = implode ( $ headerArray , "\r\n" ) ; } return $ headerArray ; }
Convert every header values to one line and merge multiple values with comma.

@param array $headers  Headers to convert,
@param bool  $toString If true, will implode all header lines with line break.

@return  array|string  Converted headers.
Convert every header values to one line and merge multiple values with comma .