Does anyone know why this might execute so slowly?
Here's the page http://www.dio.org/catholictimes/cnsmovie.php
Here's the code.
function cnsmovie(){
$number = date('y').'mv';
$suffix = '.htm';
//varies from year to year. This number represents the first posted review of 2004. I assume they increase by 1 for each posted review.
$movNum = 300;
$theurl = 'http://www.catholicnews.com/data/movies/'.$number.$movNum.$suffix;
$contents = "";
//this moves through the list of posted reviews until it can't find one.
while($handle = fopen($theurl, 'r'))
{
$movNum += 1;
$theurl = 'http://www.catholicnews.com/data/movies/'.$number.$movNum.$suffix;
}
//moves the pointer back to the last known good review url
$movNum -= rand(1,4);
$theurl = 'http://www.catholicnews.com/data/movies/'.$number.$movNum.$suffix;
$handle = fopen($theurl, 'r');
while(!feof($handle)){
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
}
$start = strpos($contents, "<b>Movie Review</b>");
$end = strpos($contents, "END<br>");
$stringEnd = substr($contents, $end);
$stringEndLen = strlen($stringEnd);
$stringEndLen = -($stringEndLen);
$contents = substr($contents, $start, $stringEndLen);
$contents = strip_tags($contents, "<p>, <b>, <br>");
echo '<p class="department">'.$contents.'</p>';
echo '<p class="emphasis"><a href="http://www.catholicnews.com/movies.htm" target="new">For more CNS Movie reviews, Click Here</a></p>';
fclose($handle);
}
Any help would be appreciated.