Fredrik
Fredrik

Reputation: 635

Get title from link, PHP Simple HTML DOM Parser

I'm trying to get the title from a link - which I already have identified, it is just the last bit with retrieving the title from the same link.

To find the right link I use this code:

$html->find('a[href=http://mylink.se']');

But I also want the title from this link. How would I do that?

Upvotes: 0

Views: 5520

Answers (1)

Alex Turpin
Alex Turpin

Reputation: 47776

Assuming you're using PHP Simple HTML DOM parser, which is not clear in your question, you could do

$link = $html->find('a[href=http://mylink.se]', 0); //As the OP pointed out in comments, you need to select the first element
$title = $link->title

http://simplehtmldom.sourceforge.net/manual.htm

Upvotes: 2

Related Questions