php - How to select second element between multiple identical classname? -
i have structure this:
<div class="test"> <span>one</span> </div> <div class="test"> <span>two</span> </div> <div class="test"> <span>three</span> </div>
and here code:
foreach($html->find('div[class=test]') $article) { echo $type .= $article->find('span',0)->plaintext."<br>"; }
and here current result:
one 2 3
and here expected result:
two
how can that?
note: use this php library.
$data = $html->find('div[class=test]', 1); echo $type .= $data->find('span',0)->plaintext."<br>";
that should print want 1 second div
element select (starts @ 0 first 1 = 0, 2nd = 1).
Comments
Post a Comment