If you are using fsockopen to access webpage, but come across a redirect (Location: ) in the header and want to find and follow the redirect as in this snippet:
<?php
while (!feof($fp)) {
$line=fgets($fp, 1024);
if (stristr($line,"location:")!="") {
$redirect=preg_replace("/location:/i","",$line);
}
}
?>
Then don't forget to <?php $redirect = trim($redirect); ?> before trying to follow this new link as $redirect actually has a \r\n on the end of it and won't give you a valid path in the next iteration otherwise. A six hour bug.
Saul Dobney