phoenixx Posted September 24, 2008 Share Posted September 24, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.