3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <p>Some random text <iframe src="the link"" width="425" height="350" frameborder="0"></iframe></p> HTML; libxml_use_internal_errors(true); $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); foreach ($dom->getElementsByTagName('iframe') as $iframe) { $iframe->setAttribute('data-src', $iframe->getAttribute('src')); $iframe->removeAttribute('src'); } echo $dom->saveHTML();

preferences:
32.28 ms | 408 KiB | 6 Q