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; } if (0 === $xml = $this->xml->$offset) { $xml = $this->xml[$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']; var_dump((string)$simple->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.70.0130.00918.57
8.3.60.0110.00416.88
8.3.50.0200.01416.87
8.3.40.0040.01119.22
8.3.30.0040.01119.09
8.3.20.0040.00419.10
8.3.10.0060.00319.15
8.3.00.0050.00319.63
8.2.180.0120.00617.00
8.2.170.0070.01022.96
8.2.160.0140.00421.39
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.88
8.2.110.0090.00019.39
8.2.100.0040.00817.97
8.2.90.0030.00721.28
8.2.80.0040.00419.53
8.2.70.0080.00017.86
8.2.60.0000.00818.04
8.2.50.0000.00818.07
8.2.40.0040.00818.30
8.2.30.0040.00418.29
8.2.20.0000.00817.95
8.2.10.0040.00417.86
8.2.00.0030.00618.12
8.1.280.0090.00625.92
8.1.270.0090.00024.66
8.1.260.0060.00326.35
8.1.250.0070.00028.09
8.1.240.0040.00422.70
8.1.230.0110.00021.20
8.1.220.0050.00317.91
8.1.210.0000.00819.05
8.1.200.0060.00317.60
8.1.190.0040.00417.78
8.1.180.0050.00318.10
8.1.170.0060.00318.96
8.1.160.0020.00519.08
8.1.150.0000.00818.92
8.1.140.0040.00417.71
8.1.130.0000.00718.05
8.1.120.0000.00717.80
8.1.110.0030.00617.71
8.1.100.0000.00817.60
8.1.90.0040.00417.75
8.1.80.0000.00717.59
8.1.70.0060.00317.62
8.1.60.0080.00017.82
8.1.50.0040.00417.77
8.1.40.0040.00417.64
8.1.30.0000.00817.79
8.1.20.0040.00417.90
8.1.10.0050.00317.71
8.1.00.0030.00617.63
8.0.300.0080.00020.33
8.0.290.0000.00817.00
8.0.280.0000.00718.73
8.0.270.0070.00017.45
8.0.260.0070.00018.55
8.0.250.0000.00717.25
8.0.240.0080.00017.27
8.0.230.0070.00017.17
8.0.220.0030.00317.21
8.0.210.0070.00017.21
8.0.200.0060.00017.25
8.0.190.0070.00017.11
8.0.180.0040.00417.11
8.0.170.0000.00817.09
8.0.160.0050.00217.17
8.0.150.0040.00417.17
8.0.140.0040.00417.22
8.0.130.0000.00513.52
8.0.120.0000.00717.07
8.0.110.0000.00717.20
8.0.100.0050.00216.98
8.0.90.0040.00417.21
8.0.80.0130.00717.23
8.0.70.0040.00417.18
8.0.60.0000.00717.19
8.0.50.0000.00717.11
8.0.30.0090.00917.45
8.0.20.0090.01017.17
8.0.10.0000.00817.24
8.0.00.0100.01417.01
7.4.330.0020.00213.26
7.4.320.0000.00616.86
7.4.300.0030.00316.79
7.4.290.0000.00716.68
7.4.280.0050.00316.91
7.4.270.0050.00316.91
7.4.260.0070.00013.52
7.4.250.0060.00316.61
7.4.240.0000.00816.79
7.4.230.0040.00416.53
7.4.220.0100.01016.73
7.4.210.0070.01216.75
7.4.200.0000.00816.65
7.4.190.0050.00316.96
7.4.160.0100.01416.66
7.4.150.0130.01016.46
7.4.140.0080.00916.84
7.4.130.0080.01016.75
7.4.120.0080.01116.79
7.4.110.0100.01316.54
7.4.100.0100.00716.77
7.4.90.0110.00716.79
7.4.80.0070.01019.39
7.4.70.0030.01316.80
7.4.60.0120.00616.88
7.4.50.0130.00016.57
7.4.40.0070.00716.71
7.4.30.0060.01816.82
7.4.00.0090.00615.07
7.3.330.0000.00613.41
7.3.320.0030.00313.60
7.3.310.0040.00416.63
7.3.300.0070.00016.46
7.3.290.0120.01216.57
7.3.280.0110.00916.58
7.3.270.0070.01116.51
7.3.260.0150.00616.65
7.3.250.0090.01316.69
7.3.240.0130.00716.55
7.3.230.0060.01016.56
7.3.210.0090.00916.93
7.3.200.0140.00716.66
7.3.190.0100.01016.80
7.3.180.0130.00316.65
7.3.170.0070.01116.57
7.3.160.0160.00016.70
7.3.120.0110.00715.07
7.2.330.0060.01216.95
7.2.320.0070.01416.91
7.2.310.0140.00717.05
7.2.300.0110.00717.00
7.2.290.0100.00917.00
7.2.00.0100.00319.72
7.1.200.0100.00315.80
7.1.70.0030.00517.26
7.1.60.0130.01019.40
7.1.50.0030.01417.08
7.1.00.0030.07722.58
7.0.200.0080.00016.63
7.0.140.0030.06722.04
7.0.120.0030.07322.12
7.0.60.0170.06720.12
7.0.50.0000.05017.98
7.0.40.0070.08017.95
7.0.30.0070.05317.90
7.0.20.0070.06717.79
7.0.10.0030.04717.79
7.0.00.0000.08317.76
5.6.280.0070.07321.16
5.6.210.0000.09020.51
5.6.200.0030.05718.29
5.6.190.0070.04018.23
5.6.180.0070.08018.30
5.6.170.0170.07018.28
5.6.160.0070.08318.35
5.6.150.0130.07018.31
5.6.140.0170.06018.30
5.6.130.0030.05718.22
5.6.120.0170.06718.27
5.6.110.0100.03718.21
5.6.100.0130.08318.29
5.6.90.0030.06718.27
5.6.80.0000.04317.74
5.6.70.0000.04017.61
5.6.60.0000.04017.59
5.6.50.0070.03317.61
5.6.40.0030.04017.58
5.6.30.0000.04717.64
5.6.20.0100.03017.58
5.6.10.0000.04017.71
5.6.00.0070.03717.70
5.5.350.0270.06020.46
5.5.340.0100.03318.18
5.5.330.0000.04718.06
5.5.320.0070.07318.11
5.5.310.0070.08017.99
5.5.300.0100.08018.15
5.5.290.0070.08318.16
5.5.280.0070.06318.02
5.5.270.0000.05018.12
5.5.260.0100.03718.14
5.5.250.0170.07017.80
5.5.240.0070.03717.59
5.5.230.0000.04317.56
5.5.220.0030.04017.50
5.5.210.0070.03317.54
5.5.200.0000.04017.44
5.5.190.0000.04017.42
5.5.180.0030.03717.44
5.5.160.0000.04017.48
5.5.150.0000.04017.53
5.5.140.0030.03717.34
5.5.130.0070.03317.40
5.5.120.0030.03717.57
5.5.110.0030.03717.55
5.5.100.0030.03717.25
5.5.90.0100.03017.40
5.5.80.0070.03317.27
5.5.70.0000.04017.29
5.5.60.0000.04317.40
5.5.50.0070.03317.30
5.5.40.0000.03717.24
5.5.30.0030.04317.40
5.5.20.0030.03717.29
5.5.10.0070.03317.34
5.5.00.0100.04717.41
5.4.450.0070.08019.59
5.4.440.0030.05019.54
5.4.430.0100.07319.54
5.4.420.0000.05719.51
5.4.410.0100.05319.38
5.4.400.0130.02719.20
5.4.390.0070.03319.12
5.4.380.0030.03719.21
5.4.370.0100.03019.06
5.4.360.0070.03319.34
5.4.350.0070.03319.34
5.4.340.0100.03018.96
5.4.320.0030.03718.96
5.4.310.0100.03019.06
5.4.300.0030.04019.27
5.4.290.0070.03318.96
5.4.280.0030.03719.05
5.4.270.0070.03319.17
5.4.260.0030.04319.13
5.4.250.0030.03719.18
5.4.240.0030.03719.14
5.4.230.0030.04019.21
5.4.220.0000.04319.05
5.4.210.0070.03319.20
5.4.200.0100.03019.07
5.4.190.0030.03719.20
5.4.180.0100.03319.13
5.4.170.0130.03019.20
5.4.160.0030.04019.17
5.4.150.0070.05319.01
5.4.140.0070.05016.52
5.4.130.0030.04016.70
5.4.120.0000.07316.61
5.4.110.0030.07716.51
5.4.100.0100.07016.52
5.4.90.0000.05016.71
5.4.80.0070.07016.65
5.4.70.0100.06716.56
5.4.60.0030.06316.66
5.4.50.0200.05716.50
5.4.40.0030.06316.65
5.4.30.0100.06716.50
5.4.20.0070.07016.61
5.4.10.0070.07316.43
5.4.00.0170.06316.14
5.3.290.0030.03714.79
5.3.280.0030.03714.67
5.3.270.0030.03714.86
5.3.260.0000.04014.77
5.3.250.0070.03314.86
5.3.240.0030.04714.68
5.3.230.0100.04014.77
5.3.220.0170.07014.61
5.3.210.0100.07314.69
5.3.200.0070.07014.77
5.3.190.0100.04014.73
5.3.180.0070.04714.70
5.3.170.0130.07014.66
5.3.160.0030.04014.68
5.3.150.0000.07314.68
5.3.140.0100.05714.82
5.3.130.0070.08014.84
5.3.120.0100.07014.74
5.3.110.0130.07014.71
5.3.100.0070.07314.17
5.3.90.0130.06714.16
5.3.80.0100.03714.17
5.3.70.0100.07014.27
5.3.60.0030.07314.11
5.3.50.0000.08013.93
5.3.40.0070.07314.07
5.3.30.0100.06713.88
5.3.20.0070.07313.82
5.3.10.0130.05013.77
5.3.00.0070.06713.62
5.2.170.0070.05011.26
5.2.160.0130.05311.13
5.2.150.0030.05011.27
5.2.140.0030.06311.27
5.2.130.0000.03311.21
5.2.120.0070.06311.35
5.2.110.0000.06311.40
5.2.100.0030.05311.34
5.2.90.0070.04311.26
5.2.80.0070.05711.24
5.2.70.0070.06011.09
5.2.60.0100.05711.26
5.2.50.0030.04711.23
5.2.40.0000.05711.15
5.2.30.0070.04711.09
5.2.20.0000.07011.10
5.2.10.0030.03710.99
5.2.00.0030.06710.84
5.1.60.0070.05710.24
5.1.50.0030.0579.98
5.1.40.0070.05310.23
5.1.30.0070.05010.48
5.1.20.0030.04310.60
5.1.10.0070.05710.21
5.1.00.0000.05710.26
5.0.50.0070.0408.83
5.0.40.0030.0338.83
5.0.30.0030.0678.83
5.0.20.0000.0438.83
5.0.10.0030.0408.83
5.0.00.0030.0508.83
4.4.90.0070.0308.83
4.4.80.0000.0338.83
4.4.70.0000.0278.83
4.4.60.0000.0208.83
4.4.50.0000.0178.83
4.4.40.0000.0478.83
4.4.30.0000.0278.83
4.4.20.0000.0378.83
4.4.10.0000.0378.83
4.4.00.0000.0438.83
4.3.110.0000.0178.83
4.3.100.0030.0378.83
4.3.90.0000.0378.83
4.3.80.0000.0608.83
4.3.70.0000.0378.83
4.3.60.0030.0278.83
4.3.50.0000.0238.83
4.3.40.0070.0238.83
4.3.30.0030.0138.83
4.3.20.0000.0178.83
4.3.10.0000.0178.83
4.3.00.0000.0278.83

preferences:
40.84 ms | 401 KiB | 5 Q