3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<EOF <table> <tr> <td>5CG </td> <td>aass </td> <td>sxs </td> <td>sx </td> <td>EK </td> <td> </td> <td>72 </td> </tr> <tr> <td> </td> <td>samplxs </td> <td>xs </td> <td> </td> <td>xss </td> <td>fkxsx aus</td> <td>s </td> </tr> <tr> <td> </td> <td>5AH. </td> <td>ds </td> <td>d </td> <td>sdf </td> <td>sdfsdf aus</td> <td> </td> </tr> <tr> <td>6CG </td> <td>3. </td> <td>sfd </td> <td> </td> <td>scs </td> <td>das aus</td> <td>a </td> </tr> <tr> <td>7DG </td> <td>6. </td> <td>s </td> <td>s </td> <td>sD </td> <td>sdsa.</td> <td> </td> </tr> <tr> <td> </td> <td>samplxs </td> <td>xs </td> <td> </td> <td>xss </td> <td>fkxsx aus</td> <td>s </td> </tr> <tr> <td>7DG, 7CG, 7CR </td> <td>6. </td> <td>NsdR </td> <td>s </td> <td>SP </td> <td>fasdlt aus</td> <td>s </td> </tr> <tr> <td> </td> <td>samplxs </td> <td>xs </td> <td> </td> <td>xss </td> <td>fkxsx aus</td> <td>s </td> </tr> <tr> <td> 9BR </td> <td>6. </td> <td>FEI </td> <td>sa </td> <td>DE </td> <td>fasdad aus</td> <td> </td> </tr> <tr> <td>9AR, 9BR, 9CR</td> <td>62. </td> <td>BEH </td> <td> </td> <td>sd </td> <td>fasda aus</td> <td> </td> </tr> <tr> <td> </td> <td>6. </td> <td>MLR </td> <td> </td> <td>FdR </td> <td>fsdfaus</td> <td> </td> </tr> <tr> <td>E10C </td> <td>6. </td> <td>sdf </td> <td>d </td> <td>d </td> <td>fsdfs aus</td> <td> </td> </tr> </table> EOF; $docH = new DOMDocument(); $docH->loadHTML($html); $xpath = new DomXpath($docH); $trs = $xpath->query('//td[contains(text(), "9BR")]/..'); foreach( $trs as $tr){ var_dump($tr); }
Output for 5.3.11 - 5.3.29, 5.4.1 - 7.1.0
object(DOMElement)#3 (18) { ["tagName"]=> string(2) "tr" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(2) "tr" ["nodeValue"]=> string(36) " 9BR 6. FEI sa DE fasdad aus " ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(2) "tr" ["baseURI"]=> NULL ["textContent"]=> string(36) " 9BR 6. FEI sa DE fasdad aus " } object(DOMElement)#4 (18) { ["tagName"]=> string(2) "tr" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(2) "tr" ["nodeValue"]=> string(42) "9AR, 9BR, 9CR 62. BEH sd fasda aus " ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(2) "tr" ["baseURI"]=> NULL ["textContent"]=> string(42) "9AR, 9BR, 9CR 62. BEH sd fasda aus " }
Output for 5.0.0 - 5.3.10, 5.4.0
object(DOMElement)#3 (0) { } object(DOMElement)#4 (0) { }
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/rlcSq on line 118
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/rlcSq on line 119
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/rlcSq on line 118