note 94717 added to function.http-parse-headers
| From: | alejosimon at osu1 dot php dot net | Date: | Thu, 19 Nov 2009 21:20:01 +0000 |
| Subject: | note 94717 added to function.http-parse-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163110@lists.php.net to get a copy of this message | ||
This works fine.
<?php
/**
* Extract the headers content from a response string.
*
* @param String raw response.
* @return Array value.
*/
function extractHeaders( $response ) {
$headers = array() ;
$fields = explode( "\n", $response ) ;
foreach ( $fields as $field ) {
$field = trim( $field ) ;
if ( $field == '' ) break ;
if ( preg_match( '/^([\w-]+):\s+(.+)/', $field, $matches ) ) {
list( $match, $name, $value ) = $matches ;
if ( isset( $headers[ $name ] ) ) {
$headers[ $name ] = (array) $headers[ $name ] ;
$headers[ $name ][] = $value ;
}
else {
$headers[ $name ] = $value ;
}
}
}
return $headers ;
}
?>
----
Server IP: 190.2.55.64
Probable Submitter: 190.51.154.145
----
Manual Page -- http://www.php.net/manual/en/function.http-parse-headers.php
Edit -- https://master.php.net/note/edit/94717
Del: integrated -- https://master.php.net/note/delete/94717/integrated
Del: useless -- https://master.php.net/note/delete/94717/useless
Del: bad code -- https://master.php.net/note/delete/94717/bad+code
Del: spam -- https://master.php.net/note/delete/94717/spam
Del: non-english -- https://master.php.net/note/delete/94717/non-english
Del: in docs -- https://master.php.net/note/delete/94717/in+docs
Del: other reasons-- https://master.php.net/note/delete/94717
Reject -- https://master.php.net/note/reject/94717
Search -- https://master.php.net/manage/user-notes.php