Get text from next tag

后端 未结 3 986
终归单人心
终归单人心 2021-01-19 09:39

I have a html snippet that looks like this (of course surrounded by other html):

Header:

Tex

相关标签:
3条回答
  • 2021-01-19 10:12

    This is untested, but you might be looking for simple_html_doms next_sibling() method.

    $html->find('p[class=finfot3]')->next_sibling()->innertext() should return the contents of the second <p> element.

    0 讨论(0)
  • 2021-01-19 10:35
    preg_match('~<p>(.*)</p>~', $html, $matches);
    var_dump($matches);
    
    0 讨论(0)
  • 2021-01-19 10:36

    Find the p element with the class. Then use

    • $e->next_sibling() - Returns the next sibling of element, or null if not found.

    where $e is the element with the class.

    For better alternatives to SimpleHtmlDom, see Best Methods to parse HTML

    0 讨论(0)
提交回复
热议问题