ali raha
ali raha

Reputation: 221

Return content of an element via simple_html_dom

I have this HTML code:

<div class="newsToolsCont">
    <span class="increaseFont">+</span>
    <span class="resetFont">A</span>
    <span class="decreaseFont">-</span>
    <span class="publishTime"></span>
    <span>2014-4-12- wed - 15:48:37</span>
</div>

I want to return content of 5th span.. How can I do it? I tried this:

$html->find('div.newsToolsCont span', 0)->innertext;

(and what is 0 in above code?)

Upvotes: 0

Views: 50

Answers (1)

Anand Patel
Anand Patel

Reputation: 3943

// Find (N)th span, returns element object or null if not found (zero based)

$html->find('div.newsToolsCont span', 4)->innertext;

Upvotes: 1

Related Questions