3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <XML> <Project Element1='some random value' Element2='Will be stored as attribute instead'/> </XML> XML; $document = new DOMDocument(); $document->loadXML($xml); $xpath = new DOMXpath($document); // iterate the first 'Project' element foreach($xpath->evaluate('(/XML/Project)[1]') as $project) { // change the attribute value $project->setAttribute('Element1', 'updated value'); } echo $document->saveXML();
Output for git.master, git.master_jit, rfc.property-hooks
<?xml version="1.0"?> <XML> <Project Element1="updated value" Element2="Will be stored as attribute instead"/> </XML>

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:
130.07 ms | 405 KiB | 5 Q