3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = " <div id='div-gpt-ad-1456499310532-2' style='height:90px; width:970px;' style=\"height:90px; width:970px;\"> </div>"; // create a new DomDocument object $doc = new DOMDocument(); // load the HTML into the DomDocument object (this would be your source HTML) $doc->loadHTML($input); removeElementsByTagName('style', $doc); // output cleaned html echo $doc->saveHtml(); function removeElementsByTagName($tagName, $document) { $nodeList = $document->getElementsByTagName($tagName); for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0; ) { $node = $nodeList->item($nodeIdx); $node->parentNode->removeChild($node); } }
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: DOMDocument::loadHTML(): Attribute style redefined in Entity, line: 2 in /in/an1lk on line 11 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><div id="div-gpt-ad-1456499310532-2" style="height:90px; width:970px;"> </div></body></html>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: DOMDocument::loadHTML(): Attribute style redefined in Entity, line: 2 in /in/an1lk on line 11 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><div id="div-gpt-ad-1456499310532-2" style="height:90px; width:970px;"> </div></body></html>

preferences:
199.4 ms | 402 KiB | 227 Q