This code returns inconsistent results. It's intended to go to the url indicated, gather the source code, and display it. You can see it in action at http://www.dio.org/catholictimes/cnsstory.php
If the story comes up incomplete, hit refresh a couple times. Eventually it displays the whole story. My thoughts are that it should either work or it shouldn't, not half and half.
function cnsstory(){
$date = date('Ymd');
$suffix = ($date-1).'.htm';
$theurl= 'http://www.catholicnews.com/data/stories/'.$suffix;
while(!($fp = fopen($theurl, 'r')))
{
$date -= 1;
$suffix = ($date-1).'.htm';
$theurl= 'http://www.catholicnews.com/data/stories/'.$suffix;
}
$fp = fopen($theurl, 'r');
$contents = fread($fp, 1000000);
echo $contents;
fclose($fp);
}
thanks