src/GetContents.php
public function parseReturnHeaders($headers)
    {
        $head = [];
        foreach ($headers as $k => $v) {
            $t = explode(':', $v, 2);
            if (isset($t[1])) {
                $head[trim($t[0])] = trim($t[1]);
            } else {
                $head[] = $v;
                if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) {
                    $head['reponse_code'] = intval($out[1]);
                }
            }
        }
        $this->debug->debug(__FUNCTION__, 'Response Header: ', $head);

        return $head;
    }
public function parseReturnHeaders($headers)
    {
        $head = [];
        foreach ($headers as $k => $v) {
            $t = explode(':', $v, 2);
            if (isset($t[1])) {
                $head[trim($t[0])] = trim($t[1]);
            } else {
                $head[] = $v;
                if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) {
                    $head['reponse_code'] = intval($out[1]);
                }
            }
        }
        $this->debug->debug(__FUNCTION__, 'Response Header: ', $head);

        return $head;
    }
public function parseReturnHeaders ( $ headers ) { $ head = [ ] ; foreach ( $ headers as $ k => $ v ) { $ t = explode ( ':' , $ v , 2 ) ; if ( isset ( $ t [ 1 ] ) ) { $ head [ trim ( $ t [ 0 ] ) ] = trim ( $ t [ 1 ] ) ; } else { $ head [ ] = $ v ; if ( preg_match ( "#HTTP/[0-9\.]+\s+([0-9]+)#" , $ v , $ out ) ) { $ head [ 'reponse_code' ] = intval ( $ out [ 1 ] ) ; } } } $ this -> debug -> debug ( __FUNCTION__ , 'Response Header: ' , $ head ) ; return $ head ; }
Parse HTTP response headers

@author: 713uk13m <dev@nguyenanhung.com>
@time  : 10/7/18 02:17

@param array $headers

@return array Header Response
Parse HTTP response headers