3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; // load source XML and create Xpath instance $source = new DOMDocument(); $source->loadxml($string); $xpath = new DOMXpath($source); // create target document with document element $target = new DOMDocument(); $root = $target->appendChild($dom->createElement('d')); // copy nodes from source to target foreach ($xpath->evaluate('/a/b/c') as $child) { $root->appendChild($target->importNode($child)); } // output target echo $target->saveXml();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $dom in /in/hlL1B on line 22 Fatal error: Uncaught Error: Call to a member function createElement() on null in /in/hlL1B:22 Stack trace: #0 {main} thrown in /in/hlL1B on line 22
Process exited with code 255.

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