note 87431 deleted from function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Thu, 04 Dec 2008 22:52:51 +0000 |
| Subject: | note 87431 deleted from function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147652@lists.php.net to get a copy of this message | ||
Note Submitter: Kai Sellgren
----
Here's a function to decode transfer chunked encoded string. Note: this works only for the
body, don't try to use this for head+body, first explode the body and head
explode("\r\n\r\n",$bodyhead,2);
<?php
function transfer_encoding_chunked_decode($encoded)
{
$decoded = '';
while (!empty($encoded))
{
$explode = explode("\r\n",$encoded,2);
$counter = hexdec($explode[0]);
$decoded .= substr($explode[1],0,$counter);
$encoded = substr($explode[1],$counter,strlen($explode[1])-$counter);
}
return $decoded;
}
?>