src/Curl/Curl.php
public function getResponseHeaders($headerKey = null)
    {
        $headers = array();
        $headerKey = strtolower($headerKey);
        
        foreach ($this->response_headers as $header) {
            $parts = explode(":", $header, 2);
            
            $key = isset($parts[0]) ? $parts[0] : null;
            $value = isset($parts[1]) ? $parts[1] : null;
            
            $headers[trim(strtolower($key))] = trim($value);
        }
        
        if ($headerKey) {
            return isset($headers[$headerKey]) ? $headers[$headerKey] : false;
        }
        
        return $headers;
    }
public function getResponseHeaders($headerKey = null)
    {
        $headers = array();
        $headerKey = strtolower($headerKey);
        
        foreach ($this->response_headers as $header) {
            $parts = explode(":", $header, 2);
            
            $key = isset($parts[0]) ? $parts[0] : null;
            $value = isset($parts[1]) ? $parts[1] : null;
            
            $headers[trim(strtolower($key))] = trim($value);
        }
        
        if ($headerKey) {
            return isset($headers[$headerKey]) ? $headers[$headerKey] : false;
        }
        
        return $headers;
    }
public function getResponseHeaders ( $ headerKey = null ) { $ headers = array ( ) ; $ headerKey = strtolower ( $ headerKey ) ; foreach ( $ this -> response_headers as $ header ) { $ parts = explode ( ":" , $ header , 2 ) ; $ key = isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : null ; $ value = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : null ; $ headers [ trim ( strtolower ( $ key ) ) ] = trim ( $ value ) ; } if ( $ headerKey ) { return isset ( $ headers [ $ headerKey ] ) ? $ headers [ $ headerKey ] : false ; } return $ headers ; }
Get a specific response header key or all values from the response headers array.

Usage example:

```php
$curl = (new Curl())->get('http://example.com');

echo $curl->getResponseHeaders('Content-Type');
```

Or in order to dump all keys with the given values use:

```php
$curl = (new Curl())->get('http://example.com');

var_dump($curl->getResponseHeaders());
```

@param string $headerKey Optional key to get from the array.
@return bool|string|array
@since 1.9
Get a specific response header key or all values from the response headers array .