3v4l.org

run code in 300+ PHP versions simultaneously
<?php function do_it($in) { $a = new DOMDocument(); $a->loadHTML($in); $xpath = new DOMXpath($a); foreach($xpath->query('/html/body//ul') as $node) _handle_uls($node); return $a->textContent; } function _handle_uls(DOMNode $node) { foreach (iterator_to_array($node->childNodes) as $subnode) { $textNode = $subnode->ownerDocument->createTextNode('* ' . trim($subnode->textContent) . "\n"); $subnode->ownerDocument->importNode($textNode); $subnode->parentNode->replaceChild($textNode, $subnode); } } $HTML = '<ul><li>Potatoes</li><li>Tomatoes</li><li>Carrots: <ul><li>Green carrots</li><li>Yellow carrots</li></ul></li></ul>'; echo do_it($HTML);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Couldn't fetch DOMElement. Node no longer exists in /in/8aoOo:17 Stack trace: #0 /in/8aoOo(10): _handle_uls(Object(DOMElement)) #1 /in/8aoOo(26): do_it('<ul><li>Potatoe...') #2 {main} thrown in /in/8aoOo on line 17
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:
63.16 ms | 401 KiB | 8 Q