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.0070.01018.68
8.3.50.0100.00822.17
8.3.40.0120.00319.16
8.3.30.0110.01119.13
8.3.20.0080.00019.12
8.3.10.0030.00521.30
8.3.00.0030.00522.11
8.2.180.0100.00717.00
8.2.170.0190.00022.96
8.2.160.0040.01120.77
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0000.01021.32
8.2.110.0050.00520.79
8.2.100.0080.00418.09
8.2.90.0040.00419.47
8.2.80.0000.00817.97
8.2.70.0060.00617.88
8.2.60.0050.00318.29
8.2.50.0000.01418.07
8.2.40.0000.00818.41
8.2.30.0070.00021.36
8.2.20.0000.00818.00
8.2.10.0000.00918.04
8.2.00.0050.00318.08
8.1.280.0160.00025.92
8.1.270.0000.00823.99
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0070.00422.71
8.1.230.0070.00421.26
8.1.220.0080.00018.77
8.1.210.0030.00719.22
8.1.200.0090.00017.85
8.1.190.0040.00417.91
8.1.180.0060.00318.10
8.1.170.0060.00319.00
8.1.160.0000.00719.07
8.1.150.0020.00518.91
8.1.140.0040.00417.75
8.1.130.0030.00318.08
8.1.120.0000.00817.82
8.1.110.0080.00017.79
8.1.100.0040.00417.64
8.1.90.0020.00517.64
8.1.80.0040.00417.64
8.1.70.0000.00717.75
8.1.60.0030.00617.71
8.1.50.0000.00817.78
8.1.40.0000.00817.75
8.1.30.0040.00417.98
8.1.20.0050.00317.84
8.1.10.0000.00817.76
8.1.00.0030.00517.87
8.0.300.0040.00420.37
8.0.290.0040.00417.55
8.0.280.0040.00418.74
8.0.270.0070.00017.60
8.0.260.0070.00017.18
8.0.250.0090.00017.18
8.0.240.0080.00317.25
8.0.230.0070.00017.21
8.0.220.0040.00417.32
8.0.210.0030.00317.30
8.0.200.0030.00317.22
8.0.190.0040.00417.33
8.0.180.0000.00717.29
8.0.170.0000.00817.29
8.0.160.0040.00417.21
8.0.150.0040.00417.27
8.0.140.0070.00017.32
8.0.130.0030.00313.77
8.0.120.0040.00417.10
8.0.110.0000.00717.31
8.0.100.0000.00717.09
8.0.90.0000.00817.37
8.0.80.0130.00617.24
8.0.70.0040.00417.38
8.0.60.0000.00817.18
8.0.50.0000.00717.30
8.0.30.0130.00717.50
8.0.20.0100.01517.40
8.0.10.0000.00817.24
8.0.00.0080.01017.22
7.4.330.0050.00017.01
7.4.320.0000.00717.02
7.4.300.0000.00716.77
7.4.290.0080.00016.94
7.4.280.0000.00916.73
7.4.270.0030.00316.74
7.4.260.0000.00613.50
7.4.250.0000.00816.84
7.4.240.0030.00316.91
7.4.230.0000.00816.88
7.4.220.0070.01716.85
7.4.210.0070.00816.87
7.4.200.0000.00716.61
7.4.190.0000.00716.73
7.4.160.0090.00616.75
7.4.150.0110.00617.40
7.4.140.0120.00817.86
7.4.130.0110.00816.87
7.4.120.0130.00816.91
7.4.110.0110.00616.89
7.4.100.0090.00917.01
7.4.90.0110.00716.87
7.4.80.0100.01319.39
7.4.70.0080.00816.85
7.4.60.0060.01016.78
7.4.50.0060.00316.61
7.4.40.0050.00822.77
7.4.30.0090.00816.79
7.4.00.0130.00315.45
7.3.330.0030.00313.69
7.3.320.0130.00013.73
7.3.310.0030.00316.53
7.3.300.0030.00316.74
7.3.290.0090.00616.75
7.3.280.0100.00516.71
7.3.270.0090.00817.40
7.3.260.0110.00918.24
7.3.250.0100.00916.82
7.3.240.0070.01016.70
7.3.230.0100.00716.91
7.3.210.0060.00916.99
7.3.200.0120.00819.39
7.3.190.0160.00716.71
7.3.180.0060.01216.79
7.3.170.0030.01416.84
7.3.160.0030.01416.85
7.3.120.0040.01115.09
7.3.10.0080.00516.86
7.3.00.0060.00916.80
7.2.330.0040.01517.14
7.2.320.0040.01317.02
7.2.310.0100.01317.09
7.2.300.0030.01316.92
7.2.290.0050.01116.85
7.2.130.0030.01017.00
7.2.120.0100.00317.02
7.2.110.0030.01016.98
7.2.100.0070.00717.02
7.2.90.0090.00016.96
7.2.80.0060.01217.10
7.2.70.0040.00817.22
7.2.60.0050.00816.98
7.2.50.0030.01017.33
7.2.40.0040.01417.21
7.2.30.0030.01517.04
7.2.20.0070.00417.18
7.2.10.0000.01216.98
7.2.00.0040.00918.23
7.1.250.0030.00716.05
7.1.200.0040.00715.76
7.1.100.0040.00418.36
7.1.70.0030.00317.16
7.1.60.0100.01319.40
7.1.50.0100.01017.15
7.1.00.0030.03322.51
7.0.200.0200.00716.77
7.0.140.0070.07022.21
7.0.80.0130.07720.04
7.0.70.0130.07720.20
7.0.60.0130.07720.01
7.0.50.0070.08320.52
7.0.40.0000.08320.15
7.0.30.0170.05320.28
7.0.20.0030.08720.19
7.0.10.0100.05320.14
7.0.00.0130.08020.21
5.6.280.0000.07721.20
5.6.230.0170.07720.83
5.6.220.0100.05020.65
5.6.210.0030.08320.81
5.6.200.0000.08721.14
5.6.190.0030.04321.14
5.6.180.0030.08321.02
5.6.170.0030.08721.08
5.6.160.0100.04721.08
5.6.150.0030.08321.14
5.6.140.0070.04021.11
5.6.130.0100.04021.27
5.6.120.0100.08321.01
5.6.110.0070.08021.23
5.6.100.0030.05721.18
5.6.90.0100.04321.13
5.6.80.0100.07020.58
5.6.70.0100.08320.57
5.6.60.0030.04720.54
5.6.50.0100.07020.38
5.6.40.0100.08320.48
5.6.30.0070.08320.55
5.6.20.0070.07720.43
5.6.10.0070.04720.54
5.6.00.0070.04320.33
5.5.370.0130.08020.62
5.5.360.0100.05320.55
5.5.350.0100.04320.56
5.5.340.0070.04320.89
5.5.330.0100.07020.89
5.5.320.0030.04720.90
5.5.310.0130.07721.02
5.5.300.0030.04320.95
5.5.290.0100.05020.79
5.5.280.0000.08020.82
5.5.270.0200.06720.97
5.5.260.0170.07721.01
5.5.250.0070.07320.70
5.5.240.0200.06320.18
5.5.230.0100.04720.16
5.5.220.0100.07720.41
5.5.210.0130.07020.24
5.5.200.0100.07020.15
5.5.190.0030.08720.31
5.5.180.0070.07320.20
5.5.160.0030.05020.39
5.5.150.0130.07720.16
5.5.140.0100.07020.39
5.5.130.0130.04320.13
5.5.120.0130.07020.36
5.5.110.0070.08020.38
5.5.100.0030.06720.16
5.5.90.0070.08020.22
5.5.80.0100.06320.19
5.5.70.0030.06720.25
5.5.60.0070.07020.21
5.5.50.0130.07020.21
5.5.40.0070.04020.18
5.5.30.0070.06720.09
5.5.20.0070.05020.25
5.5.10.0100.05720.16
5.5.00.0100.07020.23
5.4.450.0030.04319.57
5.4.440.0130.07319.57
5.4.430.0200.07019.55
5.4.420.0030.07719.25
5.4.410.0070.08319.14
5.4.400.0170.06019.13
5.4.390.0200.07019.26
5.4.380.0030.07719.24
5.4.370.0070.08019.26
5.4.360.0070.07019.11
5.4.350.0000.06319.11
5.4.340.0100.06319.11
5.4.320.0100.04019.27
5.4.310.0100.05319.25
5.4.300.0070.04019.16
5.4.290.0030.05719.32
5.4.280.0130.04019.23
5.4.270.0200.06019.28
5.4.260.0030.07319.23
5.4.250.0130.06019.24
5.4.240.0100.07019.25
5.4.230.0100.07019.28
5.4.220.0070.07719.12
5.4.210.0000.06719.23
5.4.200.0130.07719.31
5.4.190.0070.05319.24
5.4.180.0000.08019.10
5.4.170.0130.07718.96
5.4.160.0030.06019.21
5.4.150.0100.07019.21
5.4.140.0130.06016.41
5.4.130.0000.04016.48
5.4.120.0100.06716.51
5.4.110.0100.06016.58
5.4.100.0030.07716.64
5.4.90.0000.07716.55
5.4.80.0100.06716.55
5.4.70.0030.03716.68
5.4.60.0070.04316.64
5.4.50.0170.06716.57
5.4.40.0030.05316.54
5.4.30.0070.04716.57
5.4.20.0070.07316.56
5.4.10.0100.05016.57
5.4.00.0100.03315.93
5.3.290.0070.08314.90
5.3.280.0130.03314.75
5.3.270.0130.06314.83
5.3.260.0030.07714.82
5.3.250.0130.05314.69
5.3.240.0130.07014.84
5.3.230.0070.07014.76
5.3.220.0100.06714.85
5.3.210.0030.07314.85
5.3.200.0130.06014.78
5.3.190.0130.07714.76
5.3.180.0030.07714.73
5.3.170.0070.04714.79
5.3.160.0100.06714.81
5.3.150.0070.07014.65
5.3.140.0030.05714.62
5.3.130.0030.04714.71
5.3.120.0070.07714.71
5.3.110.0030.04714.77
5.3.100.0000.04014.22
5.3.90.0130.03014.07
5.3.80.0070.07014.20
5.3.70.0000.04314.28
5.3.60.0030.03714.00
5.3.50.0100.06014.21
5.3.40.0070.03714.17
5.3.30.0070.03314.18
5.3.20.0130.04713.83
5.3.10.0130.02713.88
5.3.00.0070.03313.86
5.2.170.0030.03713.41
5.2.160.0100.03713.41
5.2.150.0070.02713.41
5.2.140.0000.03313.41
5.2.130.0030.02713.41
5.2.120.0000.03013.41
5.2.110.0070.04713.41
5.2.100.0030.02713.41
5.2.90.0030.05013.41
5.2.80.0070.02713.41
5.2.70.0030.03313.41
5.2.60.0070.03713.41
5.2.50.0030.04713.41
5.2.40.0030.04013.41
5.2.30.0100.05713.41
5.2.20.0070.05313.41
5.2.10.0130.04713.41
5.2.00.0000.03313.41
5.1.60.0030.03013.41
5.1.50.0030.05713.41
5.1.40.0030.02313.41
5.1.30.0030.02713.41
5.1.20.0000.03013.41
5.1.10.0030.02713.41
5.1.00.0030.02713.41
5.0.50.0030.01713.41
5.0.40.0000.03713.41
5.0.30.0030.03013.41
5.0.20.0030.01713.41
5.0.10.0100.01313.41
5.0.00.0030.03313.41
4.4.90.0000.01713.41
4.4.80.0030.01313.41
4.4.70.0030.03313.41
4.4.60.0000.03713.41
4.4.50.0000.03713.41
4.4.40.0070.04013.41
4.4.30.0000.01713.41
4.4.20.0030.01313.41
4.4.10.0030.01713.41
4.4.00.0030.02313.41
4.3.110.0000.02013.41
4.3.100.0000.01713.41
4.3.90.0000.01713.41
4.3.80.0030.02013.41
4.3.70.0030.01313.41
4.3.60.0030.01313.41
4.3.50.0030.01313.41
4.3.40.0000.02313.41
4.3.30.0000.01713.41
4.3.20.0000.01713.41
4.3.10.0000.01713.41
4.3.00.0000.01313.41

preferences:
46.08 ms | 401 KiB | 5 Q