private function getHeadersAsArray($headersAsString)
    {
        $headers = array();

        foreach (explode("\r\n", $headersAsString) as $i => $line) {
            if (preg_match('/HTTP\/[1-2]/', substr($line, 0, 7)) === 1) { // http code
                continue;
            }

            $line = trim($line);
            if (empty($line)) {
                continue;
            }

            list($key, $value) = explode(': ', $line);

            if ($key == 'Link') {
                $value = array_merge(
                    array('_raw' => $value),
                    $this->getLinkHeaderAsArray($value)
                );
            }

            $headers[$key] = $value;
        }

        return $headers;
    }
private function getHeadersAsArray($headersAsString)
    {
        $headers = array();

        foreach (explode("\r\n", $headersAsString) as $i => $line) {
            if (preg_match('/HTTP\/[1-2]/', substr($line, 0, 7)) === 1) { // http code
                continue;
            }

            $line = trim($line);
            if (empty($line)) {
                continue;
            }

            list($key, $value) = explode(': ', $line);

            if ($key == 'Link') {
                $value = array_merge(
                    array('_raw' => $value),
                    $this->getLinkHeaderAsArray($value)
                );
            }

            $headers[$key] = $value;
        }

        return $headers;
    }
private function getHeadersAsArray ( $ headersAsString ) { $ headers = array ( ) ; foreach ( explode ( "\r\n" , $ headersAsString ) as $ i => $ line ) { if ( preg_match ( '/HTTP\/[1-2]/' , substr ( $ line , 0 , 7 ) ) === 1 ) { // http code continue ; } $ line = trim ( $ line ) ; if ( empty ( $ line ) ) { continue ; } list ( $ key , $ value ) = explode ( ': ' , $ line ) ; if ( $ key == 'Link' ) { $ value = array_merge ( array ( '_raw' => $ value ) , $ this -> getLinkHeaderAsArray ( $ value ) ) ; } $ headers [ $ key ] = $ value ; } return $ headers ; }
Get the HTTP headers as an array of header-name => header-value pairs.

The "Link" header is parsed into an associative array based on the
rel names it contains. The original value is available under
the "_raw" key.

@param string $headersAsString

@return array
Get the HTTP headers as an array of header - name = > header - value pairs .