run code in 200+ php & hhvm versions
Bugs & Features
<?php $root = new DOMDocument(); $root->formatOutput = true; $root->loadXML('<article id=""></article>'); for($i=0;$i<=300;$i++){ $node = new DOMDocument(); $node->loadXML('<section id="'.$i.'" data-country="DEU"><h1>Überschrift</h1><h2>Überschrift2</h2><p>Content</p></section>'); $xpath = new DOMXPath($node); $query = '//section'; $entries=$xpath->query($query); $entries->removeAttribute('data-country'); $entries->setAttribute("data-country", substr(md5(rand()),0,7)); $query = '//h1'; $entries=$xpath->query($query); if($entries->length===1){ $entries->item(0)->nodeValue = ""; $entries->item(0)->appendChild($node->createTextNode("Text ".$i)); } $query = '//h2'; $entries=$xpath->query($query); if($entries->length===1){ $entries->item(0)->nodeValue = ""; $entries->item(0)->appendChild($node->createTextNode(md5("Text ".$i))); } $node = $root->importNode($node->documentElement, true); $root->documentElement->appendChild($node); } print $root->saveXML();
based on BfSs4

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Arrow functions
Fatal error: Uncaught Error: Call to undefined method DOMNodeList::removeAttribute() in /in/JdsF1:15 Stack trace: #0 {main} thrown in /in/JdsF1 on line 15

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