Forum und email

http_parse_headers

(PECL pecl_http:0.10.0-1.5.5)

http_parse_headers — Analyse les en-tetes HTTP

Description

array http_parse_headers ( string $header )

Analyse les en-têtes HTTP et les placent dans un tableau associatif.

Liste de paramètres

header

chaîne contenant les en-têtes HTTP

Valeurs de retour

Retourne un tableau en cas de succès, ou FALSE si une erreur survient.

Exemples

Example#1 Exemple avec 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));
?>

L'exemple ci-dessus va afficher :

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