I've written this code to fetch some text from another site which doesn't use embedded tags, but I can only get it to retrieve the first instence properly. I added $startsearch to the strpos so that it should begin searching after it left off in the previous loop. But it doesn't! Can anyone tell me why? It seems that $startsearch isn't updating properly for some reason.
<?
function get_info($URL, $start, $end, $jumpforward, $jumpback, $numtofetch){
if(!($myFile=fopen($URL,"r")))
{
echo "Not available";
exit;
}
while(!feof($myFile))
{
$myLine.=fgets($myFile,255);
}
fclose($myFile);
$startsearch=0;
for ($i = 1; $i <= $numtofetch; $i++){
$start_position=strpos($myLine, $start, $startsearch) + $jumpforward + strlen($start);
$end_position=strpos($myLine, $end) - $jumpback;
$length=$end_position - $start_position;
$myLine=substr($myLine, $start_position, $length);
echo $myLine;
$startsearch=$start_position;
}
}
$URL="http://www.richersounds.com/cgi-bin/search.cgi?id=13";
$start="FA9775";
$jumpforward=65; //jump 65 characters
$end="FFF99D";
$jumpback=58;
$numtofetch=3;
get_info($URL, $start, $end, $jumpforward, $jumpback, $numtofetch);
?>