src/net/http/HttpRequest.php
public function getHeaders($names = null) {
        if     (!isset($names))    $names = [];
        elseif (is_string($names)) $names = [$names];
        elseif (is_array($names)) {
            foreach ($names as $i => $name) {
                if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name));
            }
        }
        else                           throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names));

        // without a name return all headers
        if (!$names) {
            return $this->headers;
        }
        return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp');
    }
public function getHeaders($names = null) {
        if     (!isset($names))    $names = [];
        elseif (is_string($names)) $names = [$names];
        elseif (is_array($names)) {
            foreach ($names as $i => $name) {
                if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name));
            }
        }
        else                           throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names));

        // without a name return all headers
        if (!$names) {
            return $this->headers;
        }
        return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp');
    }
public function getHeaders ( $ names = null ) { if ( ! isset ( $ names ) ) $ names = [ ] ; elseif ( is_string ( $ names ) ) $ names = [ $ names ] ; elseif ( is_array ( $ names ) ) { foreach ( $ names as $ i => $ name ) { if ( ! is_string ( $ name ) ) throw new IllegalTypeException ( 'Illegal type of parameter $names[' . $ i . ']: ' . gettype ( $ name ) ) ; } } else throw new IllegalTypeException ( 'Illegal type of parameter $names: ' . gettype ( $ names ) ) ; // without a name return all headers if ( ! $ names ) { return $ this -> headers ; } return \ array_intersect_ukey ( $ this -> headers , \ array_flip ( $ names ) , 'strCaseCmp' ) ; }
Return the request headers with the specified names. This method returns a key-value pair for each found header.

@param  string|string[] $names [optional] - one or more header names (case is ignored)
(default: without a name all headers are returned)

@return string[] - array of name-value pairs or an empty array if no such headers were found
Return the request headers with the specified names . This method returns a key - value pair for each found header .