3v4l.org

run code in 300+ PHP versions simultaneously
<?php function walkDOM($node) { if($node->nodeName=="pre" || $node->nodeName=="code") { return; } elseif($node->nodeName=="img") { $node->attributes->getNamedItem("src")->nodeValue=str_replace('desktop-img','mobile-img',$node->attributes->getNamedItem("src")->nodeValue); } elseif($node->hasChildNodes()) { foreach($node->childNodes as $child) { walkDOM($child); } } } function changeImagePath($html) { $dom=new DOMDocument; $dom->preserveWhiteSpace=true; $dom->loadHTML($html); $root=$dom->documentElement; walkDOM($root); $dom->formatOutput=false; return $dom->saveHTML($root); } echo changeImagePath(<<<HTML <div class="wrapper"> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> <pre> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> </pre> <code> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> </code> </div> HTML );
Output for git.master, git.master_jit, rfc.property-hooks
<html><body><div class="wrapper"> <img src="img/demo/mobile-img/sample1.jpg" width="200" height="200" alt="image"><img src="img/demo/mobile-img/sample2.jpg" width="200" height="200" alt="image"><pre> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"><img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"></pre> <code> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"><img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"></code> </div></body></html>

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:
50.29 ms | 402 KiB | 8 Q