shivam0101 Posted October 24, 2008 Share Posted October 24, 2008 The below code is going into infinite loop. When there is no new links it should come out of the loop. The code is for extracting all the links of website. function getLinks($url) { $l=array(); $fc = getContents($url); preg_match_all('/\s+href\s*=\s*[\"\']?([^\s\"\']+)[\"\'\s]+/ims', $fc, $links); if(!in_array($links[1], $l)) $l = getLinks($links[1]); //$l = $links[1]; return $l; } $links = getLinks('http://localhost/my_search/search/page_1.php'); print_r($links); Link to comment https://forums.phpfreaks.com/topic/129877-infinite-loop/ Share on other sites More sharing options...
corbin Posted October 24, 2008 Share Posted October 24, 2008 You should try passing the already matched links to the function when recalling it. Also, you should add links[1] to it before calling getLinks again. Link to comment https://forums.phpfreaks.com/topic/129877-infinite-loop/#findComment-673306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.