http_parse_headers
(PECL pecl_http >= 0.10.0)
http_parse_headers — Convierte cabeceras HTTP
Descripción
array http_parse_headers
( string
$header
)Convierte cabeceras HTTP a un array asociativo.
Parámetros
-
header -
Un string que contiene las cabeceras HTTP
Valores devueltos
Devuelve un array en caso de éxito, o FALSE en caso de error.
Ejemplos
Ejemplo #1 Uso de http_parse_headers()
<?php
$cabeceras = "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($cabeceras));
?>
El resultado del ejemplo sería:
Array
(
[Content-Type] => text/html; charset=UTF-8
[Server] => Funky/1.0
[Set-Cookie] => Array
(
[0] => foo=bar
[1] => baz=quux
)
[Folded] => works
too
)
Ver también
- http_parse_message() - Analizar mensajes HTTP
- http_parse_cookie() - Analizar una cookie HTTP