3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; public function __construct(SimpleXmlIterator $xml) { $this->xml = $xml; } public function offsetExists($offset) { return !is_null($this->xml->$offset)); } public function offsetGet($offset) { if ($this->xml->getName() == $offset) { return $this; } return new self($this->xml->$offset); } 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; } public function __toString() { return (string) $this->xml; } } $xml = '<?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading foo="bar">Reminder</heading> <body>Don\'t forget me this weekend!</body> <recursive> <val>2</val> <val>4</val> </recursive> </note>'; $simple = new SimpleXmlIterator($filePath); $xml = new XmlArrayAccessIterator($simple); echo $xml['note']['to'][0]; echo $xml['note']['recursive']['val'][0];

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.0090.04512.41
5.4.190.0130.05018.95
5.4.180.0000.05718.96
5.4.170.0030.05718.91
5.4.160.0100.04718.64
5.4.150.0070.05318.99
5.4.140.0000.05716.39
5.4.130.0030.05316.38
5.4.120.0130.04016.36
5.4.110.0100.04716.54
5.4.100.0070.05016.49
5.4.90.0030.05016.53
5.4.80.0100.04716.31
5.4.70.0070.05016.35
5.4.60.0070.07316.48
5.4.50.0130.04316.54
5.4.40.0070.05316.43
5.4.30.0130.04716.57
5.4.20.0100.04716.57
5.4.10.0170.06316.34
5.4.00.0070.04715.84
5.3.270.0070.05314.52
5.3.260.0030.05314.83
5.3.250.0070.05014.71
5.3.240.0070.05314.69
5.3.230.0330.04714.58
5.3.220.0230.06314.56
5.3.210.0100.05014.64
5.3.200.0200.03714.60
5.3.190.0130.04714.56
5.3.180.0100.05314.65
5.3.170.0130.04314.63
5.3.160.0070.07714.47
5.3.150.0000.06014.65
5.3.140.0070.07714.59
5.3.130.0030.08014.69
5.3.120.0100.05714.63
5.3.110.0130.05314.52
5.3.100.0100.04714.13
5.3.90.0030.05014.00
5.3.80.0170.03714.10
5.3.70.0070.04714.13
5.3.60.0070.04713.83
5.3.50.0030.07714.04
5.3.40.0130.04014.04
5.3.30.0100.04313.93
5.3.20.0070.05313.61
5.3.10.0000.06013.64
5.3.00.0100.05013.73

preferences:
138.93 ms | 1386 KiB | 7 Q