3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <?xml version="1.0"?> <books> <book> <isbn>123456789098</isbn> <title>Harry Potter</title> <author>J K. Rowling</author> <edition>2005</edition> </book> <book> <placeItHere></placeItHere> <isbn>1</isbn> <title>stuffs</title> <author>DA</author> <edition>2014</edition> </book> </books> XML; $book = [ 'isbn' => 123456789099, 'title' => 'Harry & Potter 3', 'author' => 'J K. Rowling', 'edition' => '2007' ]; $dom = new DOMDocument(); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; $dom->loadXML($xml); $xpath = new DOMXPath($dom); $placeItHere = $xpath->query('/books/book/placeItHere')->item(0); $newBook = $placeItHere->appendChild($dom->createElement('book')); foreach ($book as $part => $value) { $element = $newBook->appendChild($dom->createElement($part, $value)); } echo $dom->saveXML();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: DOMDocument::createElement(): unterminated entity reference Potter 3 in /in/cSeiv on line 38 <?xml version="1.0"?> <books> <book> <isbn>123456789098</isbn> <title>Harry Potter</title> <author>J K. Rowling</author> <edition>2005</edition> </book> <book> <placeItHere> <book> <isbn>123456789099</isbn> <title/> <author>J K. Rowling</author> <edition>2007</edition> </book> </placeItHere> <isbn>1</isbn> <title>stuffs</title> <author>DA</author> <edition>2014</edition> </book> </books>

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