3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $current; 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; } $this->current = $this->xml->$offset; return new self($this->xml->$offset->asXML(), false); } public function __toString() { return (string) $this->current; } 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']; //var_dump((string)$xml['note']['recursive']);

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.0060.01316.73
8.3.50.0050.01317.64
8.3.40.0080.00819.08
8.3.30.0140.00019.04
8.3.20.0050.00318.97
8.3.10.0090.00020.91
8.3.00.0030.00519.50
8.2.180.0110.01117.00
8.2.170.0070.01122.96
8.2.160.0100.00321.39
8.2.150.0030.00524.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00819.73
8.2.110.0070.00321.20
8.2.100.0080.00318.09
8.2.90.0030.00621.51
8.2.80.0000.00819.53
8.2.70.0040.00417.88
8.2.60.0050.00318.18
8.2.50.0040.00418.07
8.2.40.0080.00018.47
8.2.30.0000.00718.39
8.2.20.0080.00018.08
8.2.10.0040.00418.11
8.2.00.0050.00318.10
8.1.280.0090.00925.92
8.1.270.0040.00424.66
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0070.00322.72
8.1.230.0110.00021.16
8.1.220.0040.00417.91
8.1.210.0060.00319.14
8.1.200.0090.00017.75
8.1.190.0030.00617.88
8.1.180.0000.00818.10
8.1.170.0000.00919.22
8.1.160.0080.00019.07
8.1.150.0050.00218.90
8.1.140.0080.00017.84
8.1.130.0000.00718.05
8.1.120.0070.00017.72
8.1.110.0000.00717.68
8.1.100.0040.00317.71
8.1.90.0070.00017.73
8.1.80.0000.00717.79
8.1.70.0030.00317.74
8.1.60.0040.00417.77
8.1.50.0000.00817.80
8.1.40.0040.00417.70
8.1.30.0080.00017.93
8.1.20.0040.00417.91
8.1.10.0060.00317.88
8.1.00.0040.00417.71
8.0.300.0000.00720.36
8.0.290.0070.00017.00
8.0.280.0000.00718.58
8.0.270.0030.00317.58
8.0.260.0000.00717.10
8.0.250.0030.00617.19
8.0.240.0070.00017.27
8.0.230.0040.00417.15
8.0.220.0070.00017.13
8.0.210.0070.00017.04
8.0.200.0070.00017.22
8.0.190.0040.00417.11
8.0.180.0070.00017.17
8.0.170.0060.00317.22
8.0.160.0040.00417.13
8.0.150.0080.00317.13
8.0.140.0000.00917.14
8.0.130.0000.00613.58
8.0.120.0000.00817.07
8.0.110.0000.00817.21
8.0.100.0000.00817.11
8.0.90.0080.00017.06
8.0.80.0060.00917.05
8.0.70.0040.00416.99
8.0.60.0030.00517.05
8.0.50.0000.00817.16
8.0.30.0080.01117.46
8.0.20.0090.01317.48
8.0.10.0030.00617.09
8.0.00.0110.01216.99
7.4.330.0020.00213.21
7.4.320.0060.00016.75
7.4.300.0000.00716.92
7.4.290.0030.00316.80
7.4.280.0030.00416.74
7.4.270.0000.00716.93
7.4.260.0000.00613.56
7.4.250.0060.00316.83
7.4.240.0070.00016.79
7.4.230.0080.00016.82
7.4.220.0120.00616.94
7.4.210.0140.00416.88
7.4.200.0000.00716.83
7.4.190.0040.00416.81
7.4.160.0030.01216.86
7.4.150.0150.00916.78
7.4.140.0120.00616.62
7.4.130.0080.01316.89
7.4.120.0090.00916.81
7.4.110.0120.01016.78
7.4.100.0030.01316.73
7.4.90.0100.00716.83
7.4.80.0120.00419.39
7.4.70.0080.01016.89
7.4.60.0160.00016.86
7.4.50.0060.00016.82
7.4.40.0070.01016.62
7.4.30.0090.00616.72
7.4.00.0030.01315.17
7.3.330.0030.00313.64
7.3.320.0030.00313.41
7.3.310.0000.00716.63
7.3.300.0040.00416.50
7.3.290.0070.00716.65
7.3.280.0040.01216.64
7.3.270.0100.00716.71
7.3.260.0090.00916.65
7.3.250.0090.00816.71
7.3.240.0180.00016.83
7.3.230.0060.01116.59
7.3.210.0130.00316.67
7.3.200.0080.01416.58
7.3.190.0090.00916.67
7.3.180.0030.01216.81
7.3.170.0080.00816.71
7.3.160.0060.01016.85
7.3.120.0090.00615.33
7.2.330.0100.00716.94
7.2.320.0030.01416.71
7.2.310.0060.01316.73
7.2.300.0090.00917.04
7.2.290.0120.00616.94
7.2.00.0060.01219.66
7.1.100.0000.01018.45
7.1.70.0060.00317.31
7.1.60.0070.01719.40
7.1.50.0070.01716.99
7.1.00.0030.04722.61
7.0.200.0000.00716.90
7.0.140.0130.06322.20
7.0.120.0000.06722.03
7.0.110.0070.05722.04
7.0.100.0070.08021.86
7.0.90.0070.04721.95
7.0.80.0030.05021.91
7.0.70.0130.07021.82
7.0.60.0000.04021.68
7.0.50.0070.05321.75
7.0.40.0000.08719.86
7.0.30.0100.08019.94
7.0.20.0130.06019.88
7.0.10.0170.06019.89
7.0.00.0030.08319.82
5.6.280.0030.07021.07
5.6.260.0000.05020.82
5.6.250.0070.04320.78
5.6.240.0100.07720.71
5.6.230.0000.08720.98
5.6.220.0100.03720.78
5.6.210.0070.07320.74
5.6.200.0030.04020.71
5.6.190.0100.07320.81
5.6.180.0030.09020.77
5.6.170.0100.07720.75
5.6.160.0100.07720.75
5.6.150.0070.06320.67
5.6.140.0070.04720.74
5.6.130.0070.08020.71
5.6.120.0030.04320.75
5.6.110.0130.07720.75
5.6.100.0100.07320.67
5.6.90.0070.07320.82
5.6.80.0170.07020.09
5.6.70.0130.07020.15
5.6.60.0070.08020.05
5.6.50.0100.07720.37
5.6.40.0070.07720.10
5.6.30.0070.07720.04
5.6.20.0000.08720.18
5.6.10.0000.08020.04
5.6.00.0130.06320.10
5.5.380.0000.06017.79
5.5.370.0070.06017.59
5.5.360.0030.08317.78
5.5.350.0030.07317.45
5.5.340.0070.07018.02
5.5.330.0070.04318.01
5.5.320.0000.07718.12
5.5.310.0030.07018.17
5.5.300.0100.08018.20
5.5.290.0000.05018.00
5.5.280.0030.03718.45
5.5.270.0070.08018.36
5.5.260.0030.07718.30
5.5.250.0030.04318.01
5.5.240.0070.07017.30
5.5.230.0000.06717.75
5.5.220.0130.07017.28
5.5.210.0030.04717.52
5.5.200.0070.07717.49
5.5.190.0070.07317.36
5.5.180.0100.07317.66
5.5.160.0070.07317.36
5.5.150.0130.05317.48
5.5.140.0070.06017.26
5.5.130.0030.05017.71
5.5.120.0070.07717.63
5.5.110.0100.06017.48
5.5.100.0030.05317.46
5.5.90.0030.07317.24
5.5.80.0100.07017.37
5.5.70.0030.08317.28
5.5.60.0070.06317.52
5.5.50.0030.06017.48
5.5.40.0030.03717.45
5.5.30.0000.05017.49
5.5.20.0030.07017.52
5.5.10.0130.03317.36
5.5.00.0070.03017.44
5.4.450.0030.07719.71
5.4.440.0070.07319.71
5.4.430.0030.08019.70
5.4.420.0100.06719.55
5.4.410.0030.08019.43
5.4.400.0030.04719.09
5.4.390.0030.06019.38
5.4.380.0130.06719.23
5.4.370.0000.08019.09
5.4.360.0030.07719.38
5.4.350.0100.07319.25
5.4.340.0100.07319.22
5.4.320.0070.07719.28
5.4.310.0000.07719.42
5.4.300.0000.07019.26
5.4.290.0070.07019.06
5.4.280.0000.04719.08
5.4.270.0000.05319.26
5.4.260.0070.06319.19
5.4.250.0070.07319.21
5.4.240.0030.08319.22
5.4.230.0030.04019.41
5.4.220.0070.07319.19
5.4.210.0030.03319.24
5.4.200.0070.04319.37
5.4.190.0070.07019.22
5.4.180.0070.06719.26
5.4.170.0000.03719.22
5.4.160.0030.06319.23
5.4.150.0000.05319.07
5.4.140.0000.07716.49
5.4.130.0100.03016.78
5.4.120.0000.03716.62
5.4.110.0030.04316.50
5.4.100.0030.03016.68
5.4.90.0070.07016.77
5.4.80.0000.06716.74
5.4.70.0030.05016.79
5.4.60.0070.04016.70
5.4.50.0000.04316.77
5.4.40.0100.04716.51
5.4.30.0030.03716.52
5.4.20.0030.07716.64
5.4.10.0070.07316.60
5.4.00.0030.07016.17
5.3.290.0100.05314.75
5.3.280.0000.07014.76
5.3.270.0000.07314.77
5.3.260.0030.07014.89
5.3.250.0070.07014.68
5.3.240.0030.03714.70
5.3.230.0070.05014.78
5.3.220.0000.04014.65
5.3.210.0070.04014.86
5.3.200.0030.04014.73
5.3.190.0100.05314.66
5.3.180.0030.06714.65
5.3.170.0070.07714.79
5.3.160.0070.02714.75
5.3.150.0000.06014.80
5.3.140.0000.07314.88
5.3.130.0100.05014.73
5.3.120.0030.06314.71
5.3.110.0070.04714.75
5.3.100.0030.07014.22
5.3.90.0070.07014.10
5.3.80.0030.07714.21
5.3.70.0070.06714.18
5.3.60.0000.08014.11
5.3.50.0030.07314.16
5.3.40.0100.07014.13
5.3.30.0030.07314.23
5.3.20.0070.06313.90
5.3.10.0070.07013.88
5.3.00.0130.03013.83
5.2.170.0070.05711.82
5.2.160.0000.06711.82
5.2.150.0130.02711.82
5.2.140.0030.04311.82
5.2.130.0100.02311.82
5.2.120.0070.04711.82
5.2.110.0030.03311.82
5.2.100.0070.05711.82
5.2.90.0000.05311.82
5.2.80.0000.06311.82
5.2.70.0070.05711.82
5.2.60.0000.06711.82
5.2.50.0000.04711.82
5.2.40.0100.05711.82
5.2.30.0030.05311.82
5.2.20.0030.06311.82
5.2.10.0030.05711.82
5.2.00.0070.05711.82
5.1.60.0070.03011.82
5.1.50.0000.04711.82
5.1.40.0000.05011.82
5.1.30.0030.05311.82
5.1.20.0070.05011.82
5.1.10.0030.03011.82
5.1.00.0030.02311.82
5.0.50.0000.04011.82
5.0.40.0070.02011.82
5.0.30.0000.05711.82
5.0.20.0000.02311.82
5.0.10.0000.04011.82
5.0.00.0030.03311.82
4.4.90.0000.04011.82
4.4.80.0030.03311.82
4.4.70.0000.03711.82
4.4.60.0030.03311.82
4.4.50.0030.02311.82
4.4.40.0030.02311.82
4.4.30.0000.03711.82
4.4.20.0000.03011.82
4.4.10.0000.03011.82
4.4.00.0030.05011.82
4.3.110.0030.01711.82
4.3.100.0000.01711.82
4.3.90.0000.02711.82
4.3.80.0000.03011.82
4.3.70.0070.02311.82
4.3.60.0030.02011.82
4.3.50.0000.03011.82
4.3.40.0000.02711.82
4.3.30.0070.03011.82
4.3.20.0030.03311.82
4.3.10.0000.03311.82
4.3.00.0030.03011.82

preferences:
55.49 ms | 401 KiB | 5 Q