3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $iterator; public function __construct($filePath, $isUrl = true) { $this->isUrl = $isUrl; $this->iterator = $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; } return $this->iterator = new Test((array)$this->xml->$offset); } public function __toString() { return (string) $this->iterator[0]; } 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']; echo $xml['note']['recursive']['val'][0]; var_dump($xml->getIterator()); echo $xml;

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.0110.00418.68
8.3.50.0050.01221.34
8.3.40.0070.00719.04
8.3.30.0060.00919.08
8.3.20.0040.00419.10
8.3.10.0040.00420.79
8.3.00.0000.00919.63
8.2.180.0110.00717.25
8.2.170.0090.00622.96
8.2.160.0030.01622.38
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0040.00420.20
8.2.110.0070.00321.24
8.2.100.0060.00618.09
8.2.90.0000.00819.47
8.2.80.0030.00618.28
8.2.70.0030.00617.63
8.2.60.0000.00818.16
8.2.50.0000.00818.07
8.2.40.0040.00418.28
8.2.30.0040.00418.42
8.2.20.0040.00418.01
8.2.10.0040.00417.97
8.2.00.0000.00817.88
8.1.280.0140.00025.92
8.1.270.0000.00823.99
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0090.00022.80
8.1.230.0000.01121.16
8.1.220.0000.00818.77
8.1.210.0030.00618.93
8.1.200.0000.00917.23
8.1.190.0000.00817.65
8.1.180.0080.00018.10
8.1.170.0050.00318.88
8.1.160.0000.00719.11
8.1.150.0050.00318.84
8.1.140.0060.00317.76
8.1.130.0070.00018.07
8.1.120.0040.00417.64
8.1.110.0000.00817.59
8.1.100.0050.00217.77
8.1.90.0040.00417.59
8.1.80.0070.00017.62
8.1.70.0030.00317.63
8.1.60.0040.00417.69
8.1.50.0030.00517.63
8.1.40.0000.00917.68
8.1.30.0040.00417.89
8.1.20.0030.00617.76
8.1.10.0000.00817.77
8.1.00.0030.00517.75
8.0.300.0000.00820.19
8.0.290.0040.00417.00
8.0.280.0030.00318.52
8.0.270.0040.00417.42
8.0.260.0030.00317.04
8.0.250.0040.00417.30
8.0.240.0030.00517.12
8.0.230.0070.00017.30
8.0.220.0000.00717.09
8.0.210.0070.00017.14
8.0.200.0050.00317.16
8.0.190.0040.00417.30
8.0.180.0000.00717.14
8.0.170.0050.00417.10
8.0.160.0000.00717.14
8.0.150.0000.00817.15
8.0.140.0030.00717.18
8.0.130.0000.00513.57
8.0.120.0080.00017.05
8.0.110.0030.00517.25
8.0.100.0030.00516.98
8.0.90.0040.00417.24
8.0.80.0060.01517.15
8.0.70.0000.00717.21
8.0.60.0000.00817.21
8.0.50.0000.00817.21
8.0.30.0140.00617.33
8.0.20.0090.01017.40
8.0.10.0040.00417.22
8.0.00.0120.00616.99
7.4.330.0050.00013.43
7.4.320.0030.00316.70
7.4.300.0030.00316.69
7.4.290.0020.00516.76
7.4.280.0040.00416.87
7.4.270.0000.00716.86
7.4.260.0030.00313.34
7.4.250.0030.00616.82
7.4.240.0080.00016.79
7.4.230.0070.00016.58
7.4.220.0110.00716.84
7.4.210.0050.01116.78
7.4.200.0040.00316.81
7.4.190.0000.00716.95
7.4.160.0130.00316.75
7.4.150.0040.01517.40
7.4.140.0130.00617.31
7.4.130.0140.00816.87
7.4.120.0080.01116.85
7.4.110.0070.01016.80
7.4.100.0100.01016.65
7.4.90.0090.00916.61
7.4.80.0030.01419.03
7.4.70.0030.01316.65
7.4.60.0120.00716.70
7.4.50.0000.00816.58
7.4.40.0030.01222.27
7.4.30.0110.00917.01
7.4.00.0030.01415.15
7.3.330.0000.00613.66
7.3.320.0050.00013.38
7.3.310.0040.00416.70
7.3.300.0070.00016.51
7.3.290.0090.00616.60
7.3.280.0100.00716.61
7.3.270.0070.01117.40
7.3.260.0070.01018.24
7.3.250.0110.00816.63
7.3.240.0080.00816.49
7.3.230.0060.01416.66
7.3.210.0110.00716.64
7.3.200.0030.01919.39
7.3.190.0140.00716.59
7.3.180.0120.00616.62
7.3.170.0100.00616.70
7.3.160.0090.01216.73
7.3.120.0090.00914.87
7.2.330.0070.01116.94
7.2.320.0120.00616.61
7.2.310.0070.01116.77
7.2.300.0140.00316.63
7.2.290.0040.01416.57
7.2.60.0200.01016.98
7.1.200.0040.01215.88
7.1.70.0000.00717.40
7.1.60.0000.02519.40
7.1.50.0070.00716.98
7.1.00.0030.06722.57
7.0.200.0040.00416.96
7.0.140.0000.07322.11
7.0.60.0030.06320.14
7.0.50.0130.03717.93
7.0.40.0000.07318.00
7.0.30.0030.04717.98
7.0.20.0070.04017.92
7.0.10.0070.06717.88
7.0.00.0030.08317.88
5.6.280.0030.07320.98
5.6.210.0130.06320.72
5.6.200.0070.08018.23
5.6.190.0170.04718.22
5.6.180.0030.08018.22
5.6.170.0130.07018.33
5.6.160.0070.08018.35
5.6.150.0030.06718.41
5.6.140.0100.05718.26
5.6.130.0100.07718.30
5.6.120.0100.07718.35
5.6.110.0070.05018.30
5.6.100.0070.04318.35
5.6.90.0030.08318.24
5.6.80.0030.06017.69
5.6.70.0030.04017.64
5.6.60.0000.04717.77
5.6.50.0070.06017.70
5.6.40.0030.04717.62
5.6.30.0030.08017.58
5.6.20.0100.07317.67
5.6.10.0030.06317.60
5.6.00.0130.07017.56
5.5.350.4200.03720.43
5.5.340.0030.07018.15
5.5.330.0130.07718.03
5.5.320.0030.05718.18
5.5.310.0030.04018.02
5.5.300.0070.06718.05
5.5.290.0070.03718.05
5.5.280.0000.05318.02
5.5.270.0030.08018.05
5.5.260.0000.05018.15
5.5.250.0170.04317.98
5.5.240.0070.07717.54
5.5.230.0100.05717.54
5.5.220.0100.03317.41
5.5.210.0070.08017.40
5.5.200.0100.07717.47
5.5.190.0130.04317.39
5.5.180.0100.07017.45
5.5.160.0070.08317.38
5.5.150.0000.08317.39
5.5.140.0070.05317.50
5.5.130.0130.06017.46
5.5.120.0170.06717.53
5.5.110.0030.04317.43
5.5.100.0070.07317.34
5.5.90.0130.06717.24
5.5.80.0000.05317.38
5.5.70.0030.05017.40
5.5.60.0170.06717.45
5.5.50.0070.04317.34
5.5.40.0100.05717.40
5.5.30.0100.05017.27
5.5.20.0100.07317.26
5.5.10.0170.07017.25
5.5.00.0100.06017.41
5.4.450.0100.04319.50
5.4.440.0100.05019.51
5.4.430.0100.05319.46
5.4.420.0030.06719.56
5.4.410.0130.03719.33
5.4.400.0100.06019.13
5.4.390.0130.04019.13
5.4.380.0100.04319.23
5.4.370.0030.06019.26
5.4.360.0070.07019.06
5.4.350.0170.06718.96
5.4.340.0130.03319.13
5.4.320.0030.07318.96
5.4.310.0130.06319.21
5.4.300.0070.06019.24
5.4.290.0130.05319.26
5.4.280.0130.07019.05
5.4.270.0130.03719.26
5.4.260.0070.06719.26
5.4.250.0030.07019.03
5.4.240.0100.07319.18
5.4.230.0000.05018.95
5.4.220.0070.04719.25
5.4.210.0070.07019.10
5.4.200.0070.06319.23
5.4.190.0070.05019.14
5.4.180.0070.07319.16
5.4.170.0070.08019.25
5.4.160.0030.07719.16
5.4.150.0030.08019.14
5.4.140.0030.04016.50
5.4.130.0100.07316.41
5.4.120.0070.07716.70
5.4.110.0070.07316.50
5.4.100.0130.07016.65
5.4.90.0030.05316.58
5.4.80.0100.03716.49
5.4.70.0070.03316.52
5.4.60.0030.04016.47
5.4.50.0070.03016.52
5.4.40.0030.03316.54
5.4.30.0030.03316.49
5.4.20.0070.03016.47
5.4.10.0030.03716.51
5.4.00.0070.04015.87
5.3.290.0100.07314.83
5.3.280.0070.03714.67
5.3.270.0000.08314.67
5.3.260.0100.07714.72
5.3.250.0130.07014.66
5.3.240.0000.08014.72
5.3.230.0070.05014.86
5.3.220.0100.07014.69
5.3.210.0030.07014.73
5.3.200.0030.06714.77
5.3.190.0100.06314.82
5.3.180.0100.03714.70
5.3.170.0070.04314.68
5.3.160.0000.05014.72
5.3.150.0070.04014.72
5.3.140.0070.05014.69
5.3.130.0100.03014.70
5.3.120.0030.04314.68
5.3.110.0030.04014.81
5.3.100.0000.04014.16
5.3.90.0070.03314.18
5.3.80.0100.03714.09
5.3.70.0000.03714.09
5.3.60.0000.03714.14
5.3.50.0000.06014.05
5.3.40.0030.03713.92
5.3.30.0030.03314.05
5.3.20.0030.03713.84
5.3.10.0000.03713.79
5.3.00.0000.06713.73
5.2.170.0070.02311.26
5.2.160.0070.02311.27
5.2.150.0100.03011.28
5.2.140.0000.03011.35
5.2.130.0000.03011.08
5.2.120.0000.03011.27
5.2.110.0000.03011.26
5.2.100.0070.03011.39
5.2.90.0000.03011.11
5.2.80.0000.03011.21
5.2.70.0000.03011.07
5.2.60.0030.02711.06
5.2.50.0000.03011.14
5.2.40.0030.02711.12
5.2.30.0070.02710.97
5.2.20.0070.02310.95
5.2.10.0000.03011.11
5.2.00.0030.02710.76
5.1.60.0000.02710.13
5.1.50.0070.02010.13
5.1.40.0030.02010.16
5.1.30.0000.02710.50
5.1.20.0000.03310.48
5.1.10.0000.02710.14
5.1.00.0030.02310.00
5.0.50.0000.0238.40
5.0.40.0030.0278.50
5.0.30.0000.0338.16
5.0.20.0000.0278.21
5.0.10.0070.0178.30
5.0.00.0000.0378.21
4.4.90.0030.0137.69
4.4.80.0070.0107.69
4.4.70.0030.0137.69
4.4.60.0000.0177.69
4.4.50.0000.0177.69
4.4.40.0000.0277.69
4.4.30.0030.0137.69
4.4.20.0000.0177.69
4.4.10.0000.0177.69
4.4.00.0030.0237.69
4.3.110.0000.0207.69
4.3.100.0000.0177.69
4.3.90.0000.0177.69
4.3.80.0030.0237.69
4.3.70.0030.0177.69
4.3.60.0030.0277.69
4.3.50.0030.0337.69
4.3.40.0030.0507.69
4.3.30.0000.0207.69
4.3.20.0000.0377.69
4.3.10.0070.0307.69
4.3.00.0070.0307.69

preferences:
38.71 ms | 401 KiB | 5 Q