3v4l.org

run code in 300+ PHP versions simultaneously
<?php $codes = <<<'CODES' [column] [row] [column][/column] [column][/column] [/row] [/column] CODES; $html = str_replace(['[', ']'], ['<', '>'], $codes); libxml_use_internal_errors(true); $dom = new \DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); foreach($dom->getElementsByTagName('row') as $row) { foreach($row->getElementsByTagName('column') as $column) { $column->appendChild($dom->createTextNode('test')); $column->setAttribute('class', 'test'); } } $tags = getTags($dom->documentElement); echo var_export($tags, true); function getTags($element, $tags = []) { $tag = ['tagName' => $element->tagName]; if ($element->hasAttributes()) { foreach ($element->attributes as $attribute) { $tag['attributes'][$attribute->name] = $attribute->value; } } if ('' !== ($nodeValue = trim($element->textContent)) && false === $element->hasChildNodes()) { $tag['nodeValue'] = $nodeValue; } if ($element->hasChildNodes()) { foreach ($element->childNodes as $childElement) { if ($childElement->nodeType !== XML_ELEMENT_NODE) { continue; } $tag[] = getTags($childElement, $tags); } } $tags[] = $tag; return $tags; }
Output for git.master_jit, git.master, rfc.property-hooks
array ( 0 => array ( 'tagName' => 'column', 0 => array ( 0 => array ( 'tagName' => 'row', 0 => array ( 0 => array ( 'tagName' => 'column', 'attributes' => array ( 'class' => 'test', ), ), ), 1 => array ( 0 => array ( 'tagName' => 'column', 'attributes' => array ( 'class' => 'test', ), ), ), ), ), ), )

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:
25.94 ms | 407 KiB | 5 Q