Now, I'd like to convert the above code so again using DOM it is able to extract all urls and their anchor texts from all links residing on any chosen webpage no matter what format the links are in.
Formats such as:

Any chance I can this achieved with cURL (not using DOM) without the regex ? You know I dislike regex and prefer simplicity in coding.
Nevertheless, from your end, I'd like to see a regex sample and another sample without regex.
Oh by the way, I really prefer not to use limited functions such as the get_file() and the like. You know what I mean.

Long answer: No. It's not meant to work that way, and trying to make it work like that is making more work for yourself then you should be.

As for your formatting question.. Again that's so basic even you should know that by now.

Hint: look at this line...

PHP Code:

echo $link->getAttribute('href');

Thanks man!
As you know, that code in my original post was for scraping all links found on Google homepage.
Thanks for the hint. I have worked on it. But facing a little problem.
The 1st foreach belongs to the original script to scrape the links from Google homepage.
I now added 2 more foreach to scrape the outerhtml and innertext from each link in the hope that one of them 2 would scrape the links' anchor texts.
But, I get a blank page now.
Here is the code ...

Give me rating from 1-10 where 10 is most good.
And tell me, is not the script good enough to be part of a web crawler ?
I mean, if I put a "link submitting" form on my site and you submit your url and hit the "Crawl" button then is not this script good enough to extract all the links and their descriptions found on your submitted page ?
Ok, I cannot totally rely on this to be a web crawler as I need to add lines of code for it to have link following features and link levels following limitations as a minimum. Nevertheless, don't you think this script is a good starting point to build my own web crawler ?
I want your honest opinions Catacaustic, Sepodati, Kicken, Barad, Gw1500se, Dsmadismad or whatever the Username is.