note 50248 deleted from function.curl-setopt by nlopess
| From: | nlopess@php.net | Date: | Wed, 23 Feb 2005 11:26:39 +0000 |
| Subject: | note 50248 deleted from function.curl-setopt by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85410@lists.php.net to get a copy of this message | ||
Note Submitter: jdhawk _AT_ gmail
Reason: useless
----
If you want the same type of array with the header information as above, but dumping to a file
instead, you can use this remove_headers function. It returns just the HTTP headers in a string, and
copies the rest of the file to $out_file.
function remove_headers ($in_file,$out_file) {
$in = fopen ($in_file,'r+');
$out = fopen($out_file,'w+');
$headers = stream_get_line($in,4096,"\r\n\r\n");
fseek ($in,ftell($in)+4);
while (!feof($in)){
fputs ($out,stream_get_line($in,4096,''));
}
fclose ($in);
fclose($out);
return($headers);
}//remove headers
You can then pass the header string to the little parsing function written by Paul dot Ebermann at
esperanto dot de to get the header array.
This function is pretty quick for large files (100mb+) and seems a lot smarter and more resource
friendly than putting 100mb into a string buffer.