3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<div class="first-slide"></div> <div class="container"></div> <?php $htmlString = '<html>...</html>';//either generated, or loaded from a file $dom = new DOMDocument; $dom->loadHTML($htmlString);//or loadHTMLFile $divs = $dom->getElementsByTagName('div'); foreach($divs as $div) { if ($div->hasAttribute('class') && strstr($div->getAttribute('class'), 'first-slide')) { //$div ~= <div class='one-two-three'> $div->appendChild( '<div class="wrapper"></div>');//check the docs to see what you can do } } ?>
Output for 5.0.0 - 7.1.0
<div class="first-slide"></div> <div class="container"></div>
Output for 4.3.2 - 4.4.9
<div class="first-slide"></div> <div class="container"></div> Fatal error: Cannot instantiate non-existent class: domdocument in /in/sjKDB on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<div class="first-slide"></div> <div class="container"></div> Fatal error: Cannot instantiate non-existent class: domdocument in /in/sjKDB on line 6