3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<img title="How to" alt="How to" src="windows_en.jpg" loading="lazy" width="1280" height="720" class="img-first">'; $doc = new DOMDocument(); $doc->loadHTML($html); $imgs = $doc->getElementsByTagName('img'); foreach($imgs as $img){ $dom2 = new DOMDocument('1.0', 'utf-8'); $element = $dom2->createElement('img'); $domAttribute = $dom2->createAttribute('src'); $domAttribute->value = $img->getAttribute('src'); $element->appendChild($domAttribute); $dom2->appendChild($element); $domAttribute = $dom2->createAttribute('alt'); $domAttribute->value = $img->getAttribute('alt'); $element->appendChild($domAttribute); $dom2->appendChild($element); echo $dom2->savehtml(); }
Output for git.master_jit, git.master, rfc.property-hooks
<img src="windows_en.jpg" alt="How to">

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
96.08 ms | 405 KiB | 5 Q