3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modify_href( $href ) { return $href . '/modified'; } $string = '<div> <a href="http://somelink" class="possible-class">text</a> <a href="http://anotherlink">other text</a> </div>'; $doc = new DomDocument(); $fragment = $doc->createDocumentFragment(); $fragment->appendXML($string); $doc->appendChild($fragment); $xpath = new DOMXPath($doc); $elements = $xpath->query("//div/a"); foreach ($elements as $element) { $element->setAttribute("href", modify_href($element->getAttribute("href"))); } echo $doc->saveHTML();
Output for git.master, git.master_jit, rfc.property-hooks
<div> <a href="http://somelink/modified" class="possible-class">text</a> <a href="http://anotherlink/modified">other text</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:
28.77 ms | 405 KiB | 5 Q