3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); $htmlString = <<<_HTML <div> <a href="A"><img src="X"></a> <a href="C"><img src="X"></a> <a href="D"><img src="X"></a> <a href="E"><img src="X"></a> <a href="F"><img src="X"></a> <p> <a href="G"><img src="X"></a> </p> <a href="H">No image in this one</a> </div> _HTML; $doc = new DOMDocument(); $doc->loadHTML($htmlString, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($doc); $links = $xpath->query('//a[@href and img]'); foreach ($links as $link) { $link->setAttribute('href', 'B'); } $newHtmlString = $doc->saveHTML(); echo $newHtmlString;
Output for git.master, git.master_jit, rfc.property-hooks
<div> <a href="B"><img src="X"></a> <a href="B"><img src="X"></a> <a href="B"><img src="X"></a> <a href="B"><img src="X"></a> <a href="B"><img src="X"></a> <p> <a href="B"><img src="X"></a> </p> <a href="H">No image in this one</a> </div>

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:
46.48 ms | 401 KiB | 8 Q