update : 2015.11.03
php.shukuma.com

검색:
 
 
Parse HTTP headers

http_parse_headers

(PECL pecl_http >= 0.10.0)

http_parse_headersParse HTTP headers

설명

array http_parse_headers ( string $header )

Parses HTTP headers into an associative array.

인수

header

string containing HTTP headers

반환값

Returns an array on success실패 시 FALSE를 반환합니다.

예제

Example #1 Using http_parse_headers()

<?php
$headers 
"content-type: text/html; charset=UTF-8\r\n".
  
"Server: Funky/1.0\r\n".
  
"Set-Cookie: foo=bar\r\n".
  
"Set-Cookie: baz=quux\r\n".
  
"Folded: works\r\n\ttoo\r\n";
print_r(http_parse_headers($headers));
?>

위 예제의 출력:

Array
(
  [Content-Type] => text/html; charset=UTF-8
  [Server] => Funky/1.0
  [Set-Cookie] => Array
  (
    [0] => foo=bar
    [1] => baz=quux
  )
  [Folded] => works
    too
)

참고