3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sHtml = '<p>the info that i really need is here<p> <p class="text-right"><a class="btn btn-default espbott aplus" role="button" href="brand/google.html">Google</a></p>'; $sHtml = '<div id="wrapper">' . $sHtml . '</div>'; echo "org:\n"; echo $sHtml; echo "\n\n"; $doc = new DOMDocument(); $doc->loadHtml($sHtml); foreach( $doc->getElementsByTagName( 'a' ) as $element ) { $element->parentNode->removeChild( $element ); } echo "res:\n"; echo $doc->saveHTML($doc->getElementById('wrapper')); ?>
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
org: <div id="wrapper"><p>the info that i really need is here<p> <p class="text-right"><a class="btn btn-default espbott aplus" role="button" href="brand/google.html">Google</a></p></div> res: <div id="wrapper"><p>the info that i really need is here</p><p> </p><p class="text-right"></p></div>
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
org: <div id="wrapper"><p>the info that i really need is here<p> <p class="text-right"><a class="btn btn-default espbott aplus" role="button" href="brand/google.html">Google</a></p></div> res: <div id="wrapper"> <p>the info that i really need is here</p> <p> </p> <p class="text-right"></p> </div>

preferences:
46.86 ms | 408 KiB | 5 Q