Jump to content

How to recurse


MaxMouseDLL

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/170998-how-to-recurse/
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.