Takes a URL to an HTML document as an argument, fetches the document, extracts and prints all URLs contained within, and then repeats the process recursively for each URL it found, up to a configurable depth.
I'm reading that you are looking for a crawler, use google to search for examples! "php link crawler"