tags:

views:

28

answers:

2
+1  A: 

This is easy using the Simple HTML DOM.

$html = file_get_html('http://www.google.com/');

$linklabel = array();
$link = array();

foreach($html->find('a') as $element)
   {
     array_push($linklabel, $element->innerText);
     array_push($link, $element->href);
    }
Unicron
+1 cause you really need the rep. and it is the right answer too :D But ->label won't give the text of the hyperlink, it will return the label attribute....
Byron Whitlock
@Byron you are right, thanks, corrected!
Unicron
what is $element here. i am getting and error for the function find('a'). if u could explain a little, it will be of gr8 help
Kiran George
the actual intension of my project is to impliment mouseless browsing addon feature through a php-curl proxy server. i think u have heard about that mozilla addon https://addons.mozilla.org/en-US/firefox/addon/879/ . after getting the link labels i need to add numbers to it. then by a virtual keyboard (only number pad), i will allow physically challanged people to open the link with a soft switch.
Kiran George
A: 

You have come to the right place. Please remove your email as this is a shared community resource, not your personal Q/A machine.

So You should use simple_html_dom to parse the links. Then it becomes as simple as

$dom = file_get_html('http://www.google.com/');

// get the label of all links. see the docs for searching options
foreach ($dom->find('a') as $links)
{
    $link->innerText;
    $link->href;
}
Byron Whitlock