Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.