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($xml); $xml = new XmlArrayAccessIterator($simple); echo $xml['note']['to']; 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)
8.3.60.0070.00717.00
8.3.50.0110.00922.11
8.3.40.0040.01419.22
8.3.30.0110.00419.46
8.3.20.0030.00520.45
8.3.10.0030.00523.86
8.3.00.0040.00419.51
8.2.180.0150.00618.68
8.2.170.0110.00422.96
8.2.160.0100.01020.65
8.2.150.0070.00024.18
8.2.140.0110.00324.66
8.2.130.0140.00426.16
8.2.120.0040.00422.21
8.2.110.0050.00522.36
8.2.100.0120.00018.03
8.2.90.0080.00019.17
8.2.80.0000.00818.18
8.2.70.0030.00617.75
8.2.60.0030.00618.26
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0060.00318.48
8.2.20.0070.00017.86
8.2.10.0040.00418.23
8.2.00.0040.00418.11
8.1.280.0100.00725.92
8.1.270.0040.00424.09
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0030.00623.98
8.1.230.0110.00019.45
8.1.220.0040.00417.90
8.1.210.0050.00318.77
8.1.200.0090.00017.50
8.1.190.0050.00317.66
8.1.180.0040.00418.10
8.1.170.0030.00518.76
8.1.160.0050.00222.24
8.1.150.0000.00718.92
8.1.140.0000.00717.63
8.1.130.0050.00217.66
8.1.120.0040.00417.59
8.1.110.0040.00417.79
8.1.100.0030.00517.58
8.1.90.0040.00417.62
8.1.80.0000.00717.78
8.1.70.0030.00717.62
8.1.60.0030.00617.72
8.1.50.0000.00817.71
8.1.40.0040.00417.81
8.1.30.0030.00617.88
8.1.20.0000.00717.74
8.1.10.0040.00417.81
8.1.00.0050.00317.59
8.0.300.0070.00018.77
8.0.290.0030.00617.30
8.0.280.0040.00418.67
8.0.270.0030.00317.39
8.0.260.0070.00017.01
8.0.250.0030.00317.24
8.0.240.0050.00317.32
8.0.230.0000.00717.24
8.0.220.0000.00717.20
8.0.210.0030.00317.22
8.0.200.0000.00617.34
8.0.190.0000.00817.32
8.0.180.0040.00417.17
8.0.170.0030.00517.13
8.0.160.0070.00017.12
8.0.150.0070.00017.24
8.0.140.0000.00817.18
8.0.130.0060.00013.56
8.0.120.0040.00417.13
8.0.110.0000.00717.21
8.0.100.0050.00317.21
8.0.90.0040.00417.05
8.0.80.0160.00317.16
8.0.70.0040.00417.30
8.0.60.0070.00017.15
8.0.50.0040.00417.08
8.0.30.0070.01217.27
8.0.20.0130.00617.46
8.0.10.0030.00617.29
8.0.00.0060.01117.17
7.4.330.0000.00515.41
7.4.320.0000.00616.68
7.4.300.0060.00016.80
7.4.290.0070.00016.75
7.4.280.0060.00316.70
7.4.270.0070.00016.67
7.4.260.0030.00316.85
7.4.250.0070.00016.79
7.4.240.0030.00416.79
7.4.230.0000.00716.71
7.4.220.0080.01516.91
7.4.210.0070.00816.80
7.4.200.0000.00716.70
7.4.190.0040.00416.92
7.4.160.0110.00416.77
7.4.150.0100.00717.40
7.4.140.0120.00617.86
7.4.130.0110.00816.80
7.4.120.0120.00716.69
7.4.110.0070.01516.80
7.4.100.0070.01116.79
7.4.90.0140.00316.78
7.4.80.0110.01119.39
7.4.70.0130.00316.76
7.4.60.0050.01416.68
7.4.50.0040.00416.55
7.4.40.0090.00622.77
7.4.30.0130.00916.75
7.4.00.0030.01415.09
7.3.330.0000.00613.57
7.3.320.0000.00513.38
7.3.310.0050.00316.66
7.3.300.0040.00416.60
7.3.290.0070.01416.55
7.3.280.0120.00616.61
7.3.270.0100.00617.40
7.3.260.0090.00916.81
7.3.250.0140.00416.56
7.3.240.0140.00316.93
7.3.230.0100.00716.84
7.3.210.0100.00716.57
7.3.200.0140.00419.39
7.3.190.0100.01316.80
7.3.180.0100.00716.83
7.3.170.0040.01216.75
7.3.160.0060.01316.69
7.3.120.0090.00714.85
7.3.110.0070.01214.99
7.3.100.0060.00814.95
7.3.90.0090.00915.24
7.3.80.0080.00615.08
7.3.70.0120.00214.92
7.3.60.0070.00514.91
7.3.50.0060.00715.00
7.3.40.0040.00914.92
7.3.30.0060.00614.88
7.3.20.0080.00816.85
7.3.10.0070.00716.88
7.3.00.0070.00416.57
7.2.330.0030.01317.06
7.2.320.0090.00916.76
7.2.310.0030.01716.95
7.2.300.0060.00916.98
7.2.290.0140.00316.96
7.2.250.0060.01315.16
7.2.240.0070.01215.31
7.2.230.0050.01415.29
7.2.220.0050.01215.18
7.2.210.0110.00315.17
7.2.200.0050.00815.13
7.2.190.0080.00515.15
7.2.180.0030.01215.20
7.2.170.0030.01115.31
7.2.130.0070.00816.71
7.2.120.0050.01016.86
7.2.110.0060.00716.66
7.2.100.0060.00616.76
7.2.90.0070.00516.88
7.2.80.0050.00816.76
7.2.70.0090.00517.04
7.2.60.0050.01016.82
7.2.50.0040.01016.96
7.2.40.0050.00816.76
7.2.30.0030.01016.81
7.2.20.0060.00516.92
7.2.10.0020.00916.79
7.2.00.0080.00316.78
7.1.330.0030.01215.99
7.1.320.0030.00915.79
7.1.310.0030.01015.97
7.1.300.0030.01015.98
7.1.290.0000.00915.93
7.1.280.0050.00715.89
7.1.270.0000.01115.77
7.1.260.0060.00315.97
7.1.250.0030.00915.65
7.1.100.0060.00318.33
7.1.70.0040.00417.47
7.1.60.0030.00817.44
7.1.50.0030.01717.07
7.1.00.0030.07322.53
7.0.200.0070.01016.91
7.0.140.0030.07322.12
7.0.100.0070.07020.05
7.0.90.0130.03720.15
7.0.80.0070.04319.99
7.0.70.0270.04319.95
7.0.60.0170.04319.90
7.0.50.0100.06720.41
7.0.40.0070.06320.15
7.0.30.0070.05020.28
7.0.20.0070.05020.09
7.0.10.0130.05020.18
7.0.00.0030.08320.18
5.6.280.0000.07321.11
5.6.250.0130.07320.71
5.6.240.0100.07320.90
5.6.230.0030.04720.71
5.6.220.0070.08720.57
5.6.210.0070.04320.69
5.6.200.0100.07721.27
5.6.190.0100.04021.13
5.6.180.0100.08321.11
5.6.170.0000.05321.15
5.6.160.0130.04021.06
5.6.150.0170.07320.96
5.6.140.0070.04721.13
5.6.130.0100.04021.07
5.6.120.0170.07021.08
5.6.110.0100.04721.18
5.6.100.0030.05021.27
5.6.90.0130.06321.17
5.6.80.0030.04020.68
5.6.70.0030.07020.48
5.6.60.0100.07020.53
5.6.50.0100.06320.49
5.6.40.0000.04020.56
5.6.30.0100.07020.46
5.6.20.0100.07720.45
5.6.10.0000.07720.45
5.6.00.0100.05020.48
5.5.380.0100.03720.39
5.5.370.0100.07320.62
5.5.360.0100.07320.55
5.5.350.0070.08020.45
5.5.340.0070.08320.94
5.5.330.0070.04020.82
5.5.320.0200.04020.86
5.5.310.0100.06320.95
5.5.300.0070.07020.95
5.5.290.0070.04020.98
5.5.280.0070.07020.88
5.5.270.0070.07720.89
5.5.260.0000.04321.03
5.5.250.0070.03720.86
5.5.240.0030.07720.34
5.5.230.0100.08320.40
5.5.220.0130.06320.20
5.5.210.0070.07720.20
5.5.200.0030.06320.39
5.5.190.0000.08720.08
5.5.180.0000.08020.33
5.5.160.0100.03320.25
5.5.150.0100.05020.33
5.5.140.0000.05320.27
5.5.130.0100.03320.21
5.5.120.0070.04320.33
5.5.110.0100.06720.10
5.5.100.0070.07020.07
5.5.90.0000.08020.15
5.5.80.0030.07720.27
5.5.70.0130.05320.09
5.5.60.0100.06020.26
5.5.50.0030.07720.11
5.5.40.0070.07020.29
5.5.30.0030.08320.26
5.5.20.0070.07020.25
5.5.10.0070.08020.09
5.5.00.0030.07020.08
5.4.450.0130.05019.35
5.4.440.0170.06719.61
5.4.430.0030.05319.59
5.4.420.0070.03319.56
5.4.410.0100.07719.11
5.4.400.0100.03019.09
5.4.390.0070.05719.23
5.4.380.0030.07719.03
5.4.370.0070.07319.23
5.4.360.0030.06019.12
5.4.350.0100.03019.22
5.4.340.0100.06019.30
5.4.320.0000.06019.25
5.4.310.0100.06719.22
5.4.300.0070.06719.27
5.4.290.0030.04319.22
5.4.280.0130.04718.95
5.4.270.0030.06019.07
5.4.260.0070.03319.17
5.4.250.0070.06318.91
5.4.240.0100.05719.21
5.4.230.0070.08019.23
5.4.220.0070.07719.01
5.4.210.0030.03719.03
5.4.200.0070.06019.23
5.4.190.0100.03319.21
5.4.180.0070.07718.94
5.4.170.0130.07018.91
5.4.160.0100.06718.93
5.4.150.0100.03019.16
5.4.140.0000.06016.57
5.4.130.0030.03716.45
5.4.120.0070.03716.58
5.4.110.0030.03316.58
5.4.100.0000.07716.58
5.4.90.0100.03016.59
5.4.80.0100.04016.47
5.4.70.0000.03716.54
5.4.60.0030.03316.53
5.4.50.0030.03716.48
5.4.40.0070.07016.62
5.4.30.0030.07316.52
5.4.20.0070.03316.54
5.4.10.0100.05016.49
5.4.00.0030.07016.07
5.3.290.0100.03314.84
5.3.280.0030.06714.86
5.3.270.0100.06314.65
5.3.260.0100.04314.69
5.3.250.0030.07714.65
5.3.240.0070.03314.79
5.3.230.0100.02714.83
5.3.220.0030.06014.71
5.3.210.0030.04014.61
5.3.200.0100.04714.63
5.3.190.0070.07314.61
5.3.180.0170.05714.62
5.3.170.0070.03314.80
5.3.160.0030.08014.62
5.3.150.0070.05714.80
5.3.140.0000.04014.85
5.3.130.0070.07714.70
5.3.120.0030.06014.82
5.3.110.0100.06714.68
5.3.100.0100.06314.30
5.3.90.0070.06714.07
5.3.80.0070.08014.09
5.3.70.0030.07314.23
5.3.60.0070.07314.14
5.3.50.0030.05314.03
5.3.40.0100.06014.17
5.3.30.0070.04714.06
5.3.20.0130.03713.84
5.3.10.0100.06313.83
5.3.00.0070.03713.91
5.2.170.0030.02711.22
5.2.160.0130.05011.27
5.2.150.0030.06311.40
5.2.140.0070.06011.31
5.2.130.0070.06011.37
5.2.120.0030.06011.17
5.2.110.0030.02711.28
5.2.100.0070.06011.22
5.2.90.0030.03711.07
5.2.80.0070.05711.06
5.2.70.0100.04711.35
5.2.60.0030.05311.23
5.2.50.0030.03711.25
5.2.40.0070.06311.17
5.2.30.0070.05711.12
5.2.20.0100.05311.14
5.2.10.0070.04310.93
5.2.00.0070.05310.97
5.1.60.0030.04310.07
5.1.50.0070.02310.14
5.1.40.0070.05010.13
5.1.30.0030.04310.52
5.1.20.0070.05310.34
5.1.10.0030.05010.23
5.1.00.0000.02710.24
5.0.50.0000.0279.37
5.0.40.0070.0479.37
5.0.30.0000.0409.37
5.0.20.0100.0339.37
5.0.10.0030.0479.37
5.0.00.0070.0479.37
4.4.90.0030.0339.37
4.4.80.0000.0239.37
4.4.70.0030.0379.37
4.4.60.0070.0309.37
4.4.50.0030.0379.37
4.4.40.0030.0379.37
4.4.30.0000.0209.37
4.4.20.0030.0379.37
4.4.10.0070.0239.37
4.4.00.0030.0279.37
4.3.110.0000.0209.37
4.3.100.0000.0379.37
4.3.90.0030.0339.37
4.3.80.0000.0509.37
4.3.70.0100.0109.37
4.3.60.0030.0239.37
4.3.50.0100.0179.37
4.3.40.0070.0239.37
4.3.30.0030.0339.37
4.3.20.0000.0239.37
4.3.10.0070.0279.37
4.3.00.0000.0379.37

preferences:
42.95 ms | 401 KiB | 5 Q