note 101894 deleted from function.http-parse-message by danbrown
| From: | danbrown@php.net | Date: | Mon, 17 Jan 2011 14:31:39 +0000 |
| Subject: | note 101894 deleted from function.http-parse-message by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175825@lists.php.net to get a copy of this message | ||
Note Submitter: A.S.
----
Also, here is a modified version that will return the header as a string, and will include the
initial "HTTP/1.x" status lines in the header result:
function http_parse_response($string)
{
$header = null;
$header_values_begun = false;
$content = null;
$str = strtok($string, "\n");
$h = null;
while ($str !== false)
{
if ($h && trim($str) === '')
{
$h = false;
continue;
}
if ($h !== false)
{
$header .= $str."\n";
$h = strpos($str, ':') === false ? null : true;
}
if ($h === false)
{
$content .= $str."\n";
}
$str = strtok("\n");
}
return array($header, trim($content));
}