3v4l.org

run code in 300+ PHP versions simultaneously
<?php $buffer = <<<XML <pages> <item>about-porto</item> <item>about-porto-4</item> <item>no-route-2</item> <item>porto_home_4</item> <item>porto_home_4_old</item> </pages> XML; function XML2Array(SimpleXMLElement $parent) { $array = array(); foreach ($parent as $name => $element) { ($node = & $array[$name]) && (1 === count($node) ? $node = array($node) : 1) && $node = & $node[]; $node = $element->count() ? XML2Array($element) : trim($element); } return $array; } $xml = simplexml_load_string($buffer); $array = XML2Array($xml); $array = array($xml->getName() => $array); print_r($array);
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/Oqr5c:19 Stack trace: #0 /in/Oqr5c(29): XML2Array(Object(SimpleXMLElement)) #1 {main} thrown in /in/Oqr5c on line 19
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:
67.77 ms | 405 KiB | 5 Q