开发者

Get title from link, PHP Simple HTML DOM Parser

开发者 https://www.devze.com 2023-03-24 02:42 出处:网络
I\'m trying to get the title from a link - which I already 开发者_StackOverflow社区have identified, it is just the last bit with retrieving the title from the same link.

I'm trying to get the title from a link - which I already 开发者_StackOverflow社区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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消