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)) { var_dump($this->xml->$nodes[1][0]->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)
8.3.60.0100.00718.82
8.3.50.0130.01117.86
8.3.40.0090.00619.29
8.3.30.0130.00319.33
8.3.20.0040.00419.23
8.3.10.0040.00421.02
8.3.00.0080.00019.76
8.2.180.0080.01117.38
8.2.170.0090.00622.96
8.2.160.0150.00322.23
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0030.00626.16
8.2.120.0080.00020.26
8.2.110.0060.00321.41
8.2.100.0040.00818.28
8.2.90.0040.00419.49
8.2.80.0050.00318.13
8.2.70.0050.00518.11
8.2.60.0000.00818.18
8.2.50.0040.00418.10
8.2.40.0080.00018.47
8.2.30.0060.00318.31
8.2.20.0030.00618.21
8.2.10.0030.00618.31
8.2.00.0040.00418.25
8.1.280.0060.00925.92
8.1.270.0050.00323.99
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0000.01119.88
8.1.230.0060.00618.20
8.1.220.0000.00818.03
8.1.210.0000.00918.77
8.1.200.0030.00617.97
8.1.190.0050.00317.85
8.1.180.0000.00918.10
8.1.170.0000.00919.28
8.1.160.0000.00719.20
8.1.150.0030.00619.11
8.1.140.0040.00417.88
8.1.130.0000.00818.00
8.1.120.0020.00517.82
8.1.110.0030.00617.77
8.1.100.0000.00817.94
8.1.90.0040.00417.91
8.1.80.0030.00517.81
8.1.70.0050.00317.93
8.1.60.0080.00018.07
8.1.50.0000.00917.80
8.1.40.0030.00517.90
8.1.30.0040.00417.96
8.1.20.0030.00618.13
8.1.10.0000.00817.95
8.1.00.0000.00817.96
8.0.300.0000.00819.09
8.0.290.0000.00817.25
8.0.280.0000.00718.74
8.0.270.0040.00417.58
8.0.260.0070.00017.27
8.0.250.0080.00017.32
8.0.240.0080.00317.45
8.0.230.0030.00317.43
8.0.220.0030.00317.26
8.0.210.0030.00517.30
8.0.200.0070.00017.49
8.0.190.0000.00817.36
8.0.180.0050.00217.43
8.0.170.0030.00917.40
8.0.160.0040.00417.42
8.0.150.0000.01017.30
8.0.140.0060.00217.21
8.0.130.0050.00013.77
8.0.120.0000.00817.35
8.0.110.0030.00517.27
8.0.100.0040.00417.37
8.0.90.0040.00417.19
8.0.80.0060.00917.40
8.0.70.0070.00017.27
8.0.60.0040.00417.42
8.0.50.0050.00217.25
8.0.30.0100.01017.36
8.0.20.0080.01117.42
8.0.10.0000.00717.56
8.0.00.0080.01317.26
7.4.330.0050.00013.59
7.4.320.0000.00617.00
7.4.300.0060.00017.11
7.4.290.0040.00416.95
7.4.280.0040.00417.05
7.4.270.0030.00317.04
7.4.260.0040.00413.89
7.4.250.0040.00416.98
7.4.240.0080.00017.07
7.4.230.0050.00317.11
7.4.220.0060.01216.86
7.4.210.0080.00817.15
7.4.200.0000.00717.09
7.4.190.0000.00816.90
7.4.160.0000.01517.08
7.4.150.0100.00717.40
7.4.140.0090.00917.39
7.4.130.0100.01117.04
7.4.120.0050.01416.97
7.4.110.0060.01517.15
7.4.100.0060.01617.03
7.4.90.0120.00617.05
7.4.80.0180.00018.80
7.4.70.0110.00916.93
7.4.60.0110.00817.16
7.4.50.0040.00416.84
7.4.40.0090.00622.27
7.4.30.0000.01716.98
7.4.00.0080.00815.59
7.3.330.0000.00813.79
7.3.320.0030.00313.84
7.3.310.0030.00316.87
7.3.300.0070.00016.70
7.3.290.0050.01016.86
7.3.280.0110.01016.84
7.3.270.0060.01117.40
7.3.260.0120.00918.24
7.3.250.0190.00416.96
7.3.240.0060.01016.80
7.3.230.0100.01017.10
7.3.210.0100.01016.86
7.3.200.0030.01619.39
7.3.190.0130.00317.14
7.3.180.0030.01316.86
7.3.170.0100.01216.88
7.3.160.0070.01017.04
7.3.120.0070.01014.98
7.3.110.0070.01115.00
7.3.100.0070.01414.95
7.3.90.0100.01015.11
7.3.80.0070.00714.97
7.3.70.0090.00615.26
7.3.60.0030.01415.23
7.3.50.0070.00715.17
7.3.40.0100.00615.00
7.3.30.0070.01015.13
7.3.20.0040.00716.98
7.3.10.0100.00716.99
7.3.00.0150.00416.98
7.2.330.0130.00616.90
7.2.320.0070.01017.10
7.2.310.0060.01217.00
7.2.300.0090.00916.86
7.2.290.0130.00717.22
7.2.250.0090.00915.51
7.2.240.0100.01015.36
7.2.230.0080.00815.34
7.2.220.0030.01415.59
7.2.210.0120.00315.22
7.2.200.0040.00715.60
7.2.190.0080.00515.27
7.2.180.0100.00315.48
7.2.170.0090.00915.40
7.2.160.0070.00715.37
7.2.150.0060.01016.94
7.2.140.0030.01317.17
7.2.130.0060.00917.19
7.2.120.0060.00917.32
7.2.110.0090.00617.29
7.2.100.0100.00317.21
7.2.90.0110.00717.13
7.2.80.0030.00717.21
7.2.70.0070.01117.19
7.2.60.0040.01017.46
7.2.50.0070.00317.28
7.2.40.0060.01017.29
7.2.30.0100.00017.26
7.2.20.0060.00317.42
7.2.10.0110.00317.26
7.2.00.0100.00618.36
7.1.330.0000.01416.07
7.1.320.0000.01015.98
7.1.310.0150.00016.34
7.1.300.0070.00716.02
7.1.290.0000.01616.12
7.1.280.0060.00616.09
7.1.270.0030.00916.05
7.1.260.0070.01015.94
7.1.250.0060.01015.98
7.1.200.0070.00316.21
7.1.70.0000.00817.65
7.1.60.0070.00417.52
7.1.50.0140.01435.16
7.1.00.0030.07722.63
7.0.200.0060.01017.01
7.0.140.0030.07022.13
7.0.60.0130.06719.98
7.0.50.0030.07718.04
7.0.40.0100.07717.88
7.0.30.0130.04317.90
7.0.20.0070.08717.85
7.0.10.0170.08017.95
7.0.00.0070.08317.88
5.6.280.0100.06321.23
5.6.210.0070.07320.73
5.6.200.0070.04318.27
5.6.190.0030.04318.30
5.6.180.0000.05318.38
5.6.170.0030.09018.27
5.6.160.0030.05018.35
5.6.150.0070.08018.39
5.6.140.0030.08318.33
5.6.130.0170.07718.29
5.6.120.0100.07318.33
5.6.110.0030.06718.40
5.6.100.0070.06318.30
5.6.90.0030.08718.25
5.6.80.0100.06317.62
5.6.70.0100.05317.58
5.6.60.0100.07317.76
5.6.50.0170.07017.65
5.6.40.0000.07717.55
5.6.30.0130.07317.77
5.6.20.0070.07017.74
5.6.10.0100.04317.71
5.6.00.0000.04717.64
5.5.350.0130.08320.44
5.5.340.0130.07318.13
5.5.330.0100.07718.13
5.5.320.0030.04018.15
5.5.310.0070.08318.08
5.5.300.0200.04017.99
5.5.290.0130.06318.09
5.5.280.0070.06718.02
5.5.270.0100.05018.02
5.5.260.0100.04318.02
5.5.250.0070.07017.98
5.5.240.0130.06017.50
5.5.230.0030.08317.54
5.5.220.0100.04717.43
5.5.210.0000.08317.52
5.5.200.0030.04317.36
5.5.190.0070.07317.42
5.5.180.0070.06317.38
5.5.160.0100.07317.58
5.5.150.0000.07717.51
5.5.140.0130.04017.45
5.5.130.0070.05317.39
5.5.120.0070.06017.56
5.5.110.0070.07017.51
5.5.100.0100.07317.32
5.5.90.0070.07317.41
5.5.80.0030.05717.32
5.5.70.0100.05317.47
5.5.60.0130.05717.28
5.5.50.0130.07017.36
5.5.40.0030.04017.43
5.5.30.0030.04717.39
5.5.20.0070.04017.31
5.5.10.0130.07017.40
5.5.00.0070.07717.23
5.4.450.0070.05019.60
5.4.440.0030.08719.45
5.4.430.0100.03319.55
5.4.420.0030.06019.67
5.4.410.0030.09019.45
5.4.400.0030.08019.17
5.4.390.0070.05019.13
5.4.380.0030.05319.35
5.4.370.0100.06019.20
5.4.360.0000.07319.31
5.4.350.0030.08719.24
5.4.340.0130.06319.14
5.4.320.0000.04319.23
5.4.310.0000.04719.20
5.4.300.0230.06719.19
5.4.290.0100.05019.06
5.4.280.0130.07319.07
5.4.270.0100.07719.14
5.4.260.0070.07319.19
5.4.250.0000.07319.05
5.4.240.0070.04019.23
5.4.230.0070.06319.26
5.4.220.0100.07019.23
5.4.210.0070.04019.06
5.4.200.0070.04319.03
5.4.190.0070.05319.10
5.4.180.0100.05019.21
5.4.170.0030.07319.20
5.4.160.0030.07319.25
5.4.150.0030.04319.09
5.4.140.0130.05716.57
5.4.130.0030.07316.42
5.4.120.0100.06316.71
5.4.110.0000.08016.54
5.4.100.0100.07016.51
5.4.90.0070.07316.55
5.4.80.0030.08316.53
5.4.70.0030.07716.53
5.4.60.0030.08016.53
5.4.50.0130.03716.48
5.4.40.0030.04316.46
5.4.30.0030.07716.64
5.4.20.0070.07016.52
5.4.10.0070.04716.52
5.4.00.0170.06015.96
5.3.290.0070.08014.82
5.3.280.0070.06314.65
5.3.270.0070.07314.67
5.3.260.0070.07714.79
5.3.250.0100.06014.66
5.3.240.0070.07014.70
5.3.230.0070.07714.79
5.3.220.0030.05314.73
5.3.210.0000.06314.70
5.3.200.0100.07014.74
5.3.190.0130.07314.71
5.3.180.0100.07314.78
5.3.170.0000.06014.70
5.3.160.0200.04014.83
5.3.150.0070.07014.83
5.3.140.0030.07714.61
5.3.130.0130.07314.71
5.3.120.0070.05014.68
5.3.110.0130.06714.69
5.3.100.0130.03714.18
5.3.90.0070.07314.11
5.3.80.0100.07314.15
5.3.70.0130.07314.15
5.3.60.0100.07014.18
5.3.50.0170.06014.11
5.3.40.0000.05313.93
5.3.30.0170.04314.00
5.3.20.0000.05013.88
5.3.10.0030.03313.64
5.3.00.0030.04013.72
5.2.170.0000.05011.41
5.2.160.0100.04311.31
5.2.150.0100.05711.34
5.2.140.0000.04311.41
5.2.130.0000.03711.36
5.2.120.0000.03711.27
5.2.110.0030.02711.29
5.2.100.0030.02711.38
5.2.90.0070.02311.23
5.2.80.0030.03011.07
5.2.70.0030.02711.27
5.2.60.0030.02711.21
5.2.50.0030.02711.03
5.2.40.0070.02311.18
5.2.30.0000.03010.97
5.2.20.0000.03011.02
5.2.10.0030.02711.00
5.2.00.0000.03010.91
5.1.60.0000.03710.05
5.1.50.0030.02010.05
5.1.40.0030.02310.23
5.1.30.0030.02310.39
5.1.20.0000.02710.35
5.1.10.0000.02710.14
5.1.00.0030.02310.07
5.0.50.0000.0208.54
5.0.40.0000.0208.41
5.0.30.0030.0278.38
5.0.20.0030.0178.38
5.0.10.0000.0208.38
5.0.00.0000.0308.38
4.4.90.0000.0178.38
4.4.80.0000.0178.38
4.4.70.0000.0178.38
4.4.60.0000.0178.38
4.4.50.0000.0178.38
4.4.40.0070.0238.38
4.4.30.0070.0108.38
4.4.20.0000.0178.38
4.4.10.0000.0138.38
4.4.00.0000.0238.38
4.3.110.0000.0178.38
4.3.100.0000.0178.38
4.3.90.0000.0138.38
4.3.80.0000.0238.38
4.3.70.0030.0108.38
4.3.60.0000.0138.38
4.3.50.0000.0138.38
4.3.40.0030.0208.38
4.3.30.0000.0138.38
4.3.20.0000.0178.38
4.3.10.0000.0138.38
4.3.00.0000.0178.38

preferences:
77.8 ms | 401 KiB | 5 Q