private function _parse_headers($headers) {

        $result = array();

        // if we have nothing to work with
        if ($headers != '') {

            // split multiple headers by blank lines
            $headers = preg_split('/^\s*$/m', trim($headers));

            // iterate through the headers
            foreach($headers as $index => $header) {

                $arguments_count = func_num_args();

                // get all the lines in the header
                // lines in headers look like [name] : [value]
                // also, the first line, the status, does not have a name, so we add the name now
                preg_match_all('/^(.*?)\:\s(.*)$/m', ($arguments_count == 2 ? 'Request Method: ' : 'Status: ') . trim($header), $matches);

                // save results
                foreach ($matches[0] as $key => $value)

                    $result[$index][$matches[1][$key]] = trim($matches[2][$key]);

            }

        }

        // return headers as an array
        return $result;

    }
private function _parse_headers($headers) {

        $result = array();

        // if we have nothing to work with
        if ($headers != '') {

            // split multiple headers by blank lines
            $headers = preg_split('/^\s*$/m', trim($headers));

            // iterate through the headers
            foreach($headers as $index => $header) {

                $arguments_count = func_num_args();

                // get all the lines in the header
                // lines in headers look like [name] : [value]
                // also, the first line, the status, does not have a name, so we add the name now
                preg_match_all('/^(.*?)\:\s(.*)$/m', ($arguments_count == 2 ? 'Request Method: ' : 'Status: ') . trim($header), $matches);

                // save results
                foreach ($matches[0] as $key => $value)

                    $result[$index][$matches[1][$key]] = trim($matches[2][$key]);

            }

        }

        // return headers as an array
        return $result;

    }
private function _parse_headers ( $ headers ) { $ result = array ( ) ; // if we have nothing to work with if ( $ headers != '' ) { // split multiple headers by blank lines $ headers = preg_split ( '/^\s*$/m' , trim ( $ headers ) ) ; // iterate through the headers foreach ( $ headers as $ index => $ header ) { $ arguments_count = func_num_args ( ) ; // get all the lines in the header // lines in headers look like [name] : [value] // also, the first line, the status, does not have a name, so we add the name now preg_match_all ( '/^(.*?)\:\s(.*)$/m' , ( $ arguments_count == 2 ? 'Request Method: ' : 'Status: ' ) . trim ( $ header ) , $ matches ) ; // save results foreach ( $ matches [ 0 ] as $ key => $ value ) $ result [ $ index ] [ $ matches [ 1 ] [ $ key ] ] = trim ( $ matches [ 2 ] [ $ key ] ) ; } } // return headers as an array return $ result ; }
Parse response headers.

It parses a string containing one or more HTTP headers and returns an array of headers where each entry also
contains an associative array of <i>name</i> => <i>value</i> for each row of data in the respective header.

@param  string  $headers    A string containing one or more HTTP headers, where multiple headers are separated by
a blank line.

@return mixed               Returns an array of headers where each entry also contains an associative array of
<i>name</i> => <i>value</i> for each row of data in the respective header.

If CURLOPT_HEADER is set to FALSE or 0, this method will return an empty string.

@access private
Parse response headers .