public static function headersToArray($header_text)
    {
        $headers = array();


        foreach (explode("\r\n", $header_text) as $i => $line)
            if ($i === 0)
                $headers['http_code'] = $line;
            else
            {
                if(!empty($line) && strpos($line, ':') !== false){
                    list ($key, $value) = explode(': ', $line);

                    $headers['headers'][] = array(
                        'key' => $key,
                        'value' => $value,
                    );
                }
            }

        return $headers;
    }
public static function headersToArray($header_text)
    {
        $headers = array();


        foreach (explode("\r\n", $header_text) as $i => $line)
            if ($i === 0)
                $headers['http_code'] = $line;
            else
            {
                if(!empty($line) && strpos($line, ':') !== false){
                    list ($key, $value) = explode(': ', $line);

                    $headers['headers'][] = array(
                        'key' => $key,
                        'value' => $value,
                    );
                }
            }

        return $headers;
    }
public static function headersToArray ( $ header_text ) { $ headers = array ( ) ; foreach ( explode ( "\r\n" , $ header_text ) as $ i => $ line ) if ( $ i === 0 ) $ headers [ 'http_code' ] = $ line ; else { if ( ! empty ( $ line ) && strpos ( $ line , ':' ) !== false ) { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ headers [ 'headers' ] [ ] = array ( 'key' => $ key , 'value' => $ value , ) ; } } return $ headers ; }
Convert Header data to array

@param string $header_text
@return array
Convert Header data to array