Jump to content

break if error help


phoenixx

Recommended Posts

I just need to stop the file using break.. NOT die().... if the foreach has reached the end of the data and produces an error.  Hope you can help me.  Here's the code.

 

<?
// Let's Extract Page Links
$k = (1);
$v = (1);
$loopcount=(0);
WHILE (($k > '') || ($v > '')){
	if ($d < ''){
		echo "End of File.";
		break;
	}
$data = @file_get_contents("http://domainname.com/aos/index$growloop.html");

preg_match_all('/<p>.*?<a href="([^"]*)".*?<p>.*?href="([^"]*)"/is',$data,$out);
$d = array_combine($out[1], $out[2]);
foreach($d as $k=>$v){
$loopcount++;
echo $loopcount . " - " . $k . "<br>";
$loopcount++;
echo $loopcount . " - " . $v . "<br>";

if ($loopcount == 100){
$growloop = ($growloop + 100);
$loopcount=(0);
echo $growloop . "<br>";
}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/125651-break-if-error-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.