3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getdata() { $contents = "<table><tr><td>Row 1 Column 1</td><td>Row 1 Column 2</td></tr><tr><td>Row 2 Column 1</td><td>Row 2 Column 2</td></tr></table>"; $DOM = new DOMDocument; $DOM->loadHTML($contents); $items = $DOM->getElementsByTagName('tr'); function tdrows($elements) { $str = ""; foreach ($elements as $element) { $str .= $element->nodeValue . ", "; } return $str; } foreach ($items as $node) { echo tdrows($node->childNodes) . "<br />"; } } getdata();
Output for 5.0.0 - 7.3.0beta1
Row 1 Column 1, Row 1 Column 2, <br />Row 2 Column 1, Row 2 Column 2, <br />
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/MQ2rt on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/MQ2rt on line 6