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; } $xml = $this->xml->$offset; if (false === $xml->asXML()) { $xml = $this->xml[$offset]; if (is_null($xml)) { throw new RuntimeException('unknown node or attribute "' . $offset . '"'); } } return new self($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; } 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'][1]; echo $xml['note']['heading']['foo'];

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.0140.00018.68
8.3.50.0120.00522.14
8.3.40.0150.00019.17
8.3.30.0070.00719.34
8.3.20.0040.00420.63
8.3.10.0060.00322.22
8.3.00.0040.00422.75
8.2.180.0120.01617.25
8.2.170.0140.00722.96
8.2.160.0070.00720.94
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0060.00321.01
8.2.110.0000.01021.28
8.2.100.0060.00618.16
8.2.90.0080.00018.47
8.2.80.0000.00818.00
8.2.70.0090.00018.29
8.2.60.0080.00018.18
8.2.50.0060.00318.30
8.2.40.0050.00320.80
8.2.30.0000.00718.42
8.2.20.0040.00417.95
8.2.10.0030.00618.04
8.2.00.0000.00818.10
8.1.280.0110.00825.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0070.00422.80
8.1.230.0060.00621.35
8.1.220.0050.00518.14
8.1.210.0030.00519.09
8.1.200.0080.00017.73
8.1.190.0110.00017.73
8.1.180.0040.00718.10
8.1.170.0000.00919.02
8.1.160.0040.00722.27
8.1.150.0000.00718.98
8.1.140.0000.00817.75
8.1.130.0080.00018.04
8.1.120.0000.00717.79
8.1.110.0000.00817.78
8.1.100.0000.00817.79
8.1.90.0050.00217.65
8.1.80.0070.00017.77
8.1.70.0040.00417.77
8.1.60.0040.00417.91
8.1.50.0060.00317.86
8.1.40.0050.00317.87
8.1.30.0040.00417.93
8.1.20.0060.00318.07
8.1.10.0030.00517.93
8.1.00.0040.00417.71
8.0.300.0000.00720.41
8.0.290.0060.00617.13
8.0.280.0000.00818.73
8.0.270.0000.00717.52
8.0.260.0000.00717.19
8.0.250.0000.00717.19
8.0.240.0030.00517.32
8.0.230.0070.00017.31
8.0.220.0030.00317.14
8.0.210.0020.00517.16
8.0.200.0030.00317.37
8.0.190.0000.00717.37
8.0.180.0000.00817.14
8.0.170.0030.00517.33
8.0.160.0050.00317.19
8.0.150.0060.00317.30
8.0.140.0040.00417.23
8.0.130.0030.00613.76
8.0.120.0000.00917.16
8.0.110.0000.00717.30
8.0.100.0070.00017.30
8.0.90.0040.00417.12
8.0.80.0090.00617.31
8.0.70.0050.00217.37
8.0.60.0000.00717.11
8.0.50.0000.00717.33
8.0.30.0100.01017.33
8.0.20.0070.01317.59
8.0.10.0040.00417.35
8.0.00.0110.01017.13
7.4.330.0050.00015.38
7.4.320.0070.00016.84
7.4.300.0000.00816.91
7.4.290.0000.00817.04
7.4.280.0000.00716.91
7.4.270.0030.00516.73
7.4.260.0070.00016.80
7.4.250.0040.00416.83
7.4.240.0030.00416.90
7.4.230.0040.00416.97
7.4.220.0110.00717.00
7.4.210.0080.00716.83
7.4.200.0070.00016.58
7.4.190.0070.00016.89
7.4.160.0080.00816.82
7.4.150.0140.00517.40
7.4.140.0100.01017.86
7.4.130.0060.01216.89
7.4.120.0080.00916.72
7.4.110.0060.01216.82
7.4.100.0090.00916.95
7.4.90.0060.01616.70
7.4.80.0100.00916.84
7.4.70.0090.00916.73
7.4.60.0090.00616.71
7.4.50.0060.00316.64
7.4.40.0060.00622.77
7.4.30.0070.01016.85
7.4.10.0080.00815.11
7.4.00.0060.01115.14
7.3.330.0030.00313.67
7.3.320.0030.00313.63
7.3.310.0040.00416.67
7.3.300.0030.00316.70
7.3.290.0000.01716.69
7.3.280.0060.01016.63
7.3.270.0070.01117.40
7.3.260.0000.02016.71
7.3.250.0110.00716.69
7.3.240.0100.00716.92
7.3.230.0140.00316.64
7.3.210.0130.00616.59
7.3.200.0130.01019.39
7.3.190.0090.01516.72
7.3.180.0070.01016.82
7.3.170.0000.01816.93
7.3.160.0040.01216.76
7.3.130.0090.00615.18
7.3.120.0080.00715.06
7.3.110.0080.00815.00
7.3.100.0030.01314.98
7.3.90.0030.01014.84
7.3.80.0020.00814.87
7.3.70.0060.00615.08
7.3.60.0080.00415.00
7.3.50.0020.01115.08
7.3.40.0030.00814.97
7.3.30.0090.00315.02
7.3.20.0060.01016.92
7.3.10.0090.00516.74
7.3.00.0100.00316.64
7.2.330.0140.00417.04
7.2.320.0060.01217.02
7.2.310.0000.01617.15
7.2.300.0230.00016.84
7.2.290.0060.01517.13
7.2.260.0060.00915.17
7.2.250.0030.01415.30
7.2.240.0070.00715.28
7.2.230.0070.01015.27
7.2.220.0060.00915.42
7.2.210.0020.01215.03
7.2.200.0040.00715.15
7.2.190.0080.00815.26
7.2.180.0030.00815.18
7.2.170.0060.00815.18
7.2.160.0070.00715.30
7.2.150.0080.00517.09
7.2.140.0030.01117.13
7.2.130.0090.00317.00
7.2.120.0100.00517.15
7.2.110.0130.00317.03
7.2.100.0100.00517.03
7.2.90.0070.00717.13
7.2.80.0060.00917.04
7.2.70.0090.00817.10
7.2.60.0020.01217.06
7.2.50.0020.01417.03
7.2.40.0090.00717.19
7.2.30.0050.00617.02
7.2.20.0080.00517.18
7.2.10.0020.00817.19
7.2.00.0020.00917.94
7.1.330.0050.01015.98
7.1.320.0060.00815.92
7.1.310.0060.00816.16
7.1.300.0050.00515.83
7.1.290.0030.00716.00
7.1.280.0020.00915.92
7.1.270.0050.00915.80
7.1.260.0070.00515.94
7.1.250.0070.00716.07
7.1.240.0030.01315.84
7.1.230.0030.01016.01
7.1.220.0060.00615.86
7.1.210.0000.01415.86
7.1.200.0030.01415.75
7.1.190.0060.00915.91
7.1.180.0110.00415.77
7.1.170.0070.00715.71
7.1.160.0090.00315.81
7.1.150.0130.00315.68
7.1.140.0050.00516.05
7.1.130.0040.01115.70
7.1.120.0090.00615.99
7.1.110.0000.00915.77
7.1.100.0030.00917.14
7.1.90.0040.00715.83
7.1.80.0080.00415.95
7.1.70.0020.00816.58
7.1.60.0020.01817.78
7.1.50.0080.01016.30
7.1.40.0060.00616.16
7.1.30.0090.00615.95
7.1.20.0030.01015.86
7.1.10.0070.01015.87
7.1.00.0100.03819.29
7.0.330.0000.01015.29
7.0.320.0060.00615.44
7.0.310.0120.00615.56
7.0.300.0080.00415.48
7.0.290.0040.01115.35
7.0.280.0090.00615.50
7.0.270.0060.00615.46
7.0.260.0060.00615.20
7.0.250.0000.01215.74
7.0.240.0060.00615.55
7.0.230.0070.00715.46
7.0.220.0070.00415.39
7.0.210.0000.01315.60
7.0.200.0050.00616.11
7.0.190.0060.00615.54
7.0.180.0030.00615.58
7.0.170.0030.00915.54
7.0.160.0090.00615.59
7.0.150.0000.01215.46
7.0.140.0150.03218.85
7.0.130.0070.01015.62
7.0.120.0040.00415.57
7.0.110.0070.00715.58
7.0.100.0030.00815.42
7.0.90.0040.01115.43
7.0.80.0110.00415.89
7.0.70.0060.00615.33
7.0.60.0020.02717.77
7.0.50.0130.02016.85
7.0.40.0090.02217.03
7.0.30.0200.02016.91
7.0.20.0150.03216.97
7.0.10.0150.04216.92
7.0.00.0050.04816.98
5.6.400.0030.00714.18
5.6.390.0070.00714.57
5.6.380.0060.00914.29
5.6.370.0110.00314.36
5.6.360.0070.00314.86
5.6.350.0000.01614.51
5.6.340.0070.00714.50
5.6.330.0110.00014.68
5.6.320.0060.00914.63
5.6.310.0070.00314.32
5.6.300.0070.00714.66
5.6.290.0060.01014.69
5.6.280.0000.04217.89
5.6.270.0100.00314.61
5.6.260.0000.01414.41
5.6.250.0040.00714.28
5.6.240.0110.00414.54
5.6.230.0000.00914.86
5.6.220.0030.01014.41
5.6.210.0100.04617.57
5.6.200.0070.04516.42
5.6.190.0060.03317.47
5.6.180.0020.02417.67
5.6.170.0100.02917.61
5.6.160.0110.02217.42
5.6.150.0050.03216.53
5.6.140.0090.04016.48
5.6.130.0080.03516.41
5.6.120.0030.03217.81
5.6.110.0060.04317.78
5.6.100.0080.03517.86
5.6.90.0070.04717.87
5.6.80.0030.02517.54
5.6.70.0120.02617.33
5.6.60.0000.01414.55
5.6.50.0040.00814.25
5.6.40.0060.01014.41
5.6.30.0040.01114.55
5.6.20.0120.00414.31
5.6.10.0100.00314.40
5.6.00.0090.00614.61
5.5.380.0050.01014.33
5.5.370.0070.00714.30
5.5.360.0060.00914.30
5.5.350.0030.03517.39
5.5.340.0040.03416.32
5.5.330.0060.04517.23
5.5.320.0170.02517.53
5.5.310.0170.04517.44
5.5.300.0030.02516.28
5.5.290.0050.02916.11
5.5.280.0050.03117.78
5.5.270.0030.04617.62
5.5.260.0030.04917.83
5.5.250.0050.04217.58
5.5.240.0050.04617.44
5.5.230.0000.01414.38
5.5.220.0100.00314.32
5.5.210.0000.01414.13
5.5.200.0100.00714.31
5.5.190.0040.00814.16
5.5.180.0070.00414.27
5.5.170.0080.00814.36
5.5.160.0100.00714.43
5.5.150.0000.01414.35
5.5.140.0130.00314.48
5.5.130.0110.00814.38
5.5.120.0070.00714.17
5.5.110.0040.01114.22
5.5.100.0150.00314.20
5.5.90.0120.00914.27
5.5.80.0030.01314.26
5.5.70.0080.01114.20
5.5.60.0040.01314.30
5.5.50.0070.00714.05
5.5.40.0060.00914.21
5.5.30.0030.01414.57
5.5.20.0130.00314.11
5.5.10.0120.00614.26
5.5.00.0030.00814.27
5.4.450.0430.02615.53
5.4.440.0350.02515.27
5.4.430.0130.02815.48
5.4.420.0200.03215.32
5.4.410.0120.02914.89
5.4.400.0060.03015.07
5.4.390.0080.02915.07
5.4.380.0080.03214.96
5.4.370.0140.03515.03
5.4.360.0150.02715.08
5.4.350.0150.03314.91
5.4.340.0170.02215.00
5.4.330.0030.00611.14
5.4.320.0080.01911.91
5.4.310.0040.02311.96
5.4.300.0100.01911.90
5.4.290.0050.02411.93
5.4.280.0070.03111.87
5.4.270.0070.02211.94
5.4.260.0030.02511.94
5.4.250.0100.02712.01
5.4.240.0060.02111.78
5.4.230.0060.02111.89
5.4.220.0080.01911.96
5.4.210.0050.02711.84
5.4.200.0130.02611.78
5.4.190.0170.04811.88
5.4.180.0120.02111.96
5.4.170.0200.04811.79
5.4.160.0170.04711.86
5.4.150.0210.04511.88
5.4.140.0210.04511.75
5.4.130.0110.02511.76
5.4.120.0070.02811.62
5.4.110.0140.02111.76
5.4.100.0130.02411.75
5.4.90.0120.05211.74
5.4.80.0170.04711.75
5.4.70.0210.04211.65
5.4.60.0100.02411.58
5.4.50.0100.02411.74
5.4.40.0130.02611.63
5.4.30.0200.04311.69
5.4.20.0230.04411.69
5.4.10.0100.05411.69
5.4.00.0070.02511.38
5.3.290.0040.02811.92
5.3.280.0090.02811.82
5.3.270.0100.02811.80
5.3.260.0190.04911.86
5.3.250.0140.05011.84
5.3.240.0190.04711.74
5.3.230.0210.04711.78
5.3.220.0200.04911.73
5.3.210.0200.04911.74
5.3.200.0200.04811.63
5.3.190.0200.04611.67
5.3.180.0150.02011.79
5.3.170.0130.02411.84
5.3.160.0100.02411.72
5.3.150.0170.05011.80
5.3.140.0270.03811.80
5.3.130.0230.04311.75
5.3.120.0150.05311.76
5.3.110.0170.03511.76
5.3.100.0160.03511.39
5.3.90.0180.04511.50
5.3.80.0180.04911.46
5.3.70.0140.05411.42
5.3.60.0230.04511.47
5.3.50.0180.03511.47
5.3.40.0180.05211.37
5.3.30.0200.03311.53
5.3.20.0160.03311.33
5.3.10.0120.02911.19
5.3.00.0110.02411.22
5.2.170.0170.0359.41
5.2.160.0160.0409.42
5.2.150.0200.0419.41
5.2.140.0190.0349.42
5.2.130.0190.0349.38
5.2.120.0270.0859.38
5.2.110.0380.1069.38
5.2.100.0120.0389.38
5.2.90.0150.0359.38
5.2.80.0260.0859.38
5.2.70.0350.0759.37
5.2.60.0160.0359.32
5.2.50.0150.0339.29
5.2.40.0440.0719.27
5.2.30.0450.0759.24
5.2.20.0160.0369.23
5.2.10.0130.0369.13
5.2.00.0200.0299.00
5.1.60.0160.0268.29
5.1.50.0150.0288.29
5.1.40.0100.0318.27
5.1.30.0120.0358.62
5.1.20.0160.0308.60
5.1.10.0310.0778.31
5.1.00.0080.0408.32
5.0.50.0260.0476.80
5.0.40.0370.0306.66
5.0.30.0180.0376.48
5.0.20.0280.0666.45
5.0.10.0090.0256.43
5.0.00.0230.1126.42
4.4.90.0070.0184.78
4.4.80.0090.0164.75
4.4.70.0090.0184.76
4.4.60.0060.0204.76
4.4.50.0060.0214.77
4.4.40.0050.0334.71
4.4.30.0070.0214.76
4.4.20.0070.0204.84
4.4.10.0120.0144.85
4.4.00.0090.0314.75
4.3.110.0200.0654.67
4.3.100.0100.0154.66
4.3.90.0090.0154.64
4.3.80.0130.0824.59
4.3.70.0050.0194.63
4.3.60.0100.0144.62
4.3.50.0380.0784.63
4.3.40.0090.0254.54
4.3.30.0040.0193.30
4.3.20.0260.0573.28
4.3.10.0050.0193.24
4.3.00.0100.01315.18

preferences:
51.27 ms | 401 KiB | 5 Q