private static function fixHttpHeaderField($header)
    {
        if (!is_array($header)) {
            $header = explode("\r\n", $header);
        }
        uasort($header, function ($el) {
            return preg_match('{^content-type}i', $el) ? 1 : -1;
        });

        return $header;
    }
private static function fixHttpHeaderField($header)
    {
        if (!is_array($header)) {
            $header = explode("\r\n", $header);
        }
        uasort($header, function ($el) {
            return preg_match('{^content-type}i', $el) ? 1 : -1;
        });

        return $header;
    }
private static function fixHttpHeaderField ( $ header ) { if ( ! is_array ( $ header ) ) { $ header = explode ( "\r\n" , $ header ) ; } uasort ( $ header , function ( $ el ) { return preg_match ( '{^content-type}i' , $ el ) ? 1 : - 1 ; } ) ; return $ header ; }
A bug in PHP prevents the headers from correctly being sent when a content-type header is present and
NOT at the end of the array

This method fixes the array by moving the content-type header to the end

@link https://bugs.php.net/bug.php?id=61548
@param $header
@return array
A bug in PHP prevents the headers from correctly being sent when a content - type header is present and NOT at the end of the array