Jump to content

Infinite loop


shivam0101

Recommended Posts

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

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.