MaxMouseDLL Posted August 19, 2009 Share Posted August 19, 2009 Hello All, I have acquired a piece of code which will extract URL's from a string (Currently I'm using cURL to obtain that string) it outputs said URL's within an Array. My question is, like a spider, how would i recurse this array, getting the contents of each element with cURL and adding new URL results to the same array only if they do not already exist in the array (Wouldn't want to spider the same URL twice), and continue until there are no more elements left in the array to process. $urls = extract_html_urls( $strContent ); foreach ($urls['a']['href'] as $key => $lnk) { // Code... echo $lnk . "<br>\n"; } URL: http://chipstix.net/includes/self_spider.php I've always had problems visualising multi-dimensional arrays (Not a problem here) or fully grasping recursive functions, especially those that depend upon an array who's size is changing as it executes, i normally end up with a head-ache, this time I've decided to ask for help! Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/170998-how-to-recurse/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.