3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; public function __construct($filePath, $isUrl = true) { $this->isUrl = $isUrl; $this->xml = new SimpleXmlIterator($filePath, 0, $isUrl); } public function offsetExists($offset) { return !is_null($this->xml->$offset); } public function offsetGet($offset) { if ($this->xml->getName() == $offset) { return $this; } if (preg_match('/(\w+)\[(\d+)\]/', $offset, $nodes)) { $node = $nodes[1]; $key = $nodes[2] var_dump($this->xml->$node->asXML()); return new self($this->xml->$nodes[1][$nodes[2]]->asXML(), false); } return new self($this->xml->$offset->asXML(), false); } public function __toString() { return (string) $this->xml; } public function offsetSet($offset, $value) { throw new RuntimeException('This is readonly. writing to "' . (string) $offset . '" with value "' . (string) $value . '" not possible'); } public function offsetUnset($offset) { throw new RuntimeException('This is readonly. Unsetting "' . (string) $offset . '" not possible'); } public function getIterator() { return $this->xml; } } $str = '<?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don\'t forget me this weekend!</body> <recursive> <val>2</val> <val>4</val> </recursive> </note>'; $xml = new XmlArrayAccessIterator($str, false); //echo $xml['note']['to']; $xml['note']['recursive']['val[1]'];

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.200.0070.04212.41
5.4.190.0140.04312.39
5.4.180.0130.04112.39
5.4.170.0130.04312.40
5.4.160.0130.04512.40
5.4.150.0130.04112.39
5.4.140.0120.04012.09
5.4.130.0130.03812.06
5.4.120.0120.03812.03
5.4.110.0120.03812.02
5.4.100.0110.03812.03
5.4.90.0160.05012.03
5.4.80.0080.04412.03
5.4.70.0100.04112.02
5.4.60.0120.04112.02
5.4.50.0100.04312.02
5.4.40.0320.06412.01
5.4.30.0100.04312.01
5.4.20.0120.04212.00
5.4.10.0120.03812.01
5.4.00.0110.04111.50
5.3.270.0150.06412.72
5.3.260.0090.05012.72
5.3.250.0200.05412.72
5.3.240.0120.04712.72
5.3.230.0120.04912.71
5.3.220.0130.04712.68
5.3.210.0100.04912.68
5.3.200.0120.04712.68
5.3.190.0120.04712.68
5.3.180.0140.04712.67
5.3.170.0120.04912.67
5.3.160.0210.06812.67
5.3.150.0150.04612.67
5.3.140.0130.04612.66
5.3.130.0130.04712.66
5.3.120.0100.05012.66
5.3.110.0150.04512.65
5.3.100.0150.04212.13
5.3.90.0140.04312.10
5.3.80.0190.05612.09
5.3.70.0120.04612.09
5.3.60.0100.04712.08
5.3.50.0130.04612.02
5.3.40.0150.04312.02
5.3.30.0070.04911.98
5.3.20.0110.04611.76
5.3.10.0120.04511.73
5.3.00.0110.04411.71

preferences:
141.99 ms | 1394 KiB | 7 Q