Jayyrus
Jayyrus

Reputation: 13051

How to get the first occurrence of a tag using SImple HTML DOM Parser

i'm trying to parse an html page and get the first occurrence of a tag using method find.. this is what i try

$master = file_get_html($link);
$link1 = $master->find("span.cl");

i need to do something like

$link1[0]

is there a way to do it?

Upvotes: 2

Views: 2471

Answers (1)

stewe
stewe

Reputation: 42612

Try something like this:

$link1  = $master->find('a', 0);

this finds the first <a> for example.

Upvotes: 4

Related Questions