3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <body> <img class="size-full aligncenter" src="image-name1.jpg" alt="" width="799" height="449"> <img class="size-full aligncenter" src="image-name2.jpg" alt="" width="799" height="449"> <img class="size-full aligncenter" src="image-name3.jpg" alt="" width="799" height="449"> </body> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query('//img[@alt=""]') as $img) { $img->setAttribute( 'alt', pathinfo( $img->getAttribute('src'), PATHINFO_FILENAME ) ); } echo $dom->saveHTML();
Output for rfc.property-hooks, git.master, git.master_jit
<body> <img class="size-full aligncenter" src="image-name1.jpg" alt="image-name1" width="799" height="449"> <img class="size-full aligncenter" src="image-name2.jpg" alt="image-name2" width="799" height="449"> <img class="size-full aligncenter" src="image-name3.jpg" alt="image-name3" width="799" height="449"> </body>

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:
52.55 ms | 1308 KiB | 4 Q