3v4l.org

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

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.0080.01118.65
8.3.50.0130.00622.23
8.3.40.0110.00419.24
8.3.30.0040.01119.09
8.3.20.0090.00019.15
8.3.10.0090.00021.38
8.3.00.0040.00423.86
8.2.180.0160.00018.66
8.2.170.0110.00722.96
8.2.160.0100.00320.60
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0000.00819.63
8.2.110.0040.00422.62
8.2.100.0080.00418.09
8.2.90.0040.00419.47
8.2.80.0040.00418.27
8.2.70.0060.00617.88
8.2.60.0000.00818.15
8.2.50.0030.00618.30
8.2.40.0090.00018.41
8.2.30.0030.00620.23
8.2.20.0000.00818.05
8.2.10.0080.00018.07
8.2.00.0040.00418.02
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0070.00322.67
8.1.230.0120.00021.15
8.1.220.0060.00318.77
8.1.210.0000.00819.23
8.1.200.0040.00417.60
8.1.190.0000.00917.89
8.1.180.0030.00518.10
8.1.170.0000.00919.20
8.1.160.0000.00719.00
8.1.150.0060.00319.05
8.1.140.0000.00817.65
8.1.130.0000.00718.09
8.1.120.0050.00317.64
8.1.110.0060.00317.70
8.1.100.0030.00517.80
8.1.90.0040.00417.75
8.1.80.0000.00717.62
8.1.70.0000.00717.75
8.1.60.0040.00417.89
8.1.50.0000.00817.80
8.1.40.0040.00417.77
8.1.30.0040.00417.76
8.1.20.0030.00517.95
8.1.10.0090.00017.88
8.1.00.0000.00817.67
8.0.300.0040.00420.19
8.0.290.0040.00416.88
8.0.280.0050.00318.71
8.0.270.0030.00317.39
8.0.260.0030.00317.05
8.0.250.0040.00417.19
8.0.240.0000.00817.12
8.0.230.0030.00317.20
8.0.220.0040.00417.11
8.0.210.0000.00717.04
8.0.200.0000.00717.28
8.0.190.0000.00717.13
8.0.180.0000.00917.17
8.0.170.0060.00317.22
8.0.160.0050.00217.19
8.0.150.0030.00517.13
8.0.140.0060.00317.02
8.0.130.0030.00313.66
8.0.120.0000.00717.17
8.0.110.0060.00317.05
8.0.100.0000.00717.16
8.0.90.0040.00417.02
8.0.80.0130.00617.22
8.0.70.0000.00716.99
8.0.60.0000.00816.97
8.0.50.0000.00817.14
8.0.30.0140.00917.17
8.0.20.0040.01517.51
8.0.10.0000.00717.10
8.0.00.0150.01016.90
7.4.330.0000.00515.03
7.4.320.0040.00416.74
7.4.300.0060.00016.70
7.4.290.0030.00316.73
7.4.280.0040.00416.73
7.4.270.0080.00016.78
7.4.260.0030.00313.52
7.4.250.0030.00616.79
7.4.240.0070.00016.78
7.4.230.0030.00316.60
7.4.220.0090.00916.80
7.4.210.0070.00916.86
7.4.200.0000.00716.95
7.4.190.0000.00716.97
7.4.160.0030.01516.91
7.4.150.0150.00417.40
7.4.140.0140.00517.86
7.4.130.0100.00816.82
7.4.120.0160.00316.68
7.4.110.0110.00716.77
7.4.100.0110.00716.84
7.4.90.0170.00716.84
7.4.80.0100.00719.37
7.4.70.0060.01216.56
7.4.60.0090.00916.69
7.4.50.0080.00016.74
7.4.40.0000.01422.27
7.4.30.0140.00516.68
7.4.00.0100.00615.11
7.3.330.0030.00313.46
7.3.320.0030.00313.39
7.3.310.0000.00716.51
7.3.300.0040.00416.53
7.3.290.0120.00916.60
7.3.280.0110.00916.66
7.3.270.0090.00917.40
7.3.260.0100.00818.24
7.3.250.0060.01616.77
7.3.240.0110.00716.79
7.3.230.0120.00616.59
7.3.210.0070.01016.66
7.3.200.0070.01019.39
7.3.190.0060.01216.62
7.3.180.0090.00916.67
7.3.170.0090.00816.70
7.3.160.0180.00016.83
7.3.120.0070.00714.89
7.2.330.0150.00417.09
7.2.320.0060.01116.77
7.2.310.0150.00916.86
7.2.300.0130.00717.13
7.2.290.0090.00916.86
7.2.60.0480.00617.32
7.2.50.0040.01217.26
7.1.200.0030.00915.90
7.1.100.0060.00618.32
7.1.70.0070.00717.38
7.1.60.0070.01419.40
7.1.50.0000.01216.92
7.1.00.0070.05322.59
7.0.200.0040.00416.75
7.0.140.0070.07022.21
7.0.60.0070.06720.03
7.0.50.0030.08017.98
7.0.40.0100.07320.19
7.0.30.0530.05020.28
7.0.20.0370.07720.29
7.0.10.0300.04720.26
7.0.00.0100.04720.30
5.6.280.0030.07321.10
5.6.210.0070.05720.93
5.6.200.0100.06718.39
5.6.190.0100.07720.57
5.6.180.0130.04320.80
5.6.170.0330.08320.58
5.6.160.0130.08020.66
5.6.150.0100.06318.37
5.6.140.0170.07018.35
5.6.130.0070.04018.32
5.6.120.0130.05321.25
5.6.110.0030.08321.09
5.6.100.0030.04021.18
5.6.90.0030.08721.07
5.6.80.0130.05720.48
5.6.70.0230.06020.59
5.5.350.0170.08020.54
5.5.340.0070.05718.07
5.5.330.0170.05020.30
5.5.320.0270.08020.58
5.5.310.0170.04020.42
5.5.300.0100.04318.07
5.5.290.0070.05318.04
5.5.280.0070.06321.08
5.5.270.0170.05321.11
5.5.260.0100.08320.87
5.5.250.0100.07320.71
5.5.240.0070.05320.43
5.4.450.0230.04719.54
5.4.440.0330.03719.75
5.4.430.0330.03719.47
5.4.420.0300.04019.63
5.4.410.0330.03319.45
5.4.400.0270.04019.35
5.4.390.0330.03319.33
5.4.380.0300.04019.17
5.4.370.0270.04019.18
5.4.360.0330.03719.30
5.4.350.0330.03719.18
5.4.340.0300.03719.40
5.4.320.0300.04019.35
5.4.310.0300.03719.24
5.4.300.0330.03719.14
5.4.290.0270.04019.14
5.4.280.0370.03319.21
5.4.270.0300.03719.34
5.4.260.0370.03319.30
5.4.250.0330.03319.23
5.4.240.0370.03019.17
5.4.230.0330.03319.32
5.4.220.0400.03319.29
5.4.210.0330.03319.05
5.4.200.0370.05719.32
5.4.190.0400.03019.06
5.4.180.0400.05019.07
5.4.170.0400.07019.17
5.4.160.0370.04319.07
5.4.150.0430.06019.15
5.4.140.0400.04016.58
5.4.130.0270.03716.59
5.4.120.0270.03716.52
5.4.110.0370.05016.73
5.4.100.0370.07016.72
5.4.90.0300.04716.48
5.4.80.0370.04316.68
5.4.70.0370.05016.72
5.4.60.0330.06716.38
5.4.50.0270.04016.37
5.4.40.0470.06316.66
5.4.30.0470.05716.48
5.4.20.0430.05016.65
5.4.10.0330.03716.57
5.4.00.0330.03316.00
5.3.290.0330.04014.89
5.3.280.0430.04714.85
5.3.270.0370.03714.80
5.3.260.0330.04014.79
5.3.250.0370.03714.68
5.3.240.0330.04014.89
5.3.230.0370.05314.79
5.3.220.0470.03714.75
5.3.210.0430.06014.79
5.3.200.0270.04714.90
5.3.190.0270.05014.76
5.3.180.0370.04314.66
5.3.170.0430.06314.74
5.3.160.0330.05314.63
5.3.150.0400.06714.68
5.3.140.0400.04014.67
5.3.130.0370.07014.83
5.3.120.0400.04314.63
5.3.110.0430.06314.88
5.3.100.0370.07014.32
5.3.90.0430.06314.11
5.3.80.0470.06014.05
5.3.70.0430.03714.09
5.3.60.0400.06314.12
5.3.50.0300.04314.14
5.3.40.0300.04314.17
5.3.30.0300.03714.14
5.3.20.0400.05013.92
5.3.10.0300.03713.73
5.3.00.0400.04713.93
5.2.170.0330.05012.43
5.2.160.0300.04712.43
5.2.150.0370.04012.43
5.2.140.0270.02712.43
5.2.130.0300.02712.43
5.2.120.0230.03012.43
5.2.110.0270.02712.43
5.2.100.0300.04312.43
5.2.90.0300.06012.43
5.2.80.0300.04312.43
5.2.70.0270.02712.43
5.2.60.0330.03312.43
5.2.50.0300.05712.43
5.2.40.0300.02712.43
5.2.30.0300.05012.43
5.2.20.0400.02012.43
5.2.10.0270.02712.43
5.2.00.0200.03012.43
5.1.60.0230.02012.43
5.1.50.0200.03312.43
5.1.40.0370.02012.43
5.1.30.0300.05012.43
5.1.20.0200.02712.43
5.1.10.0300.03012.43
5.1.00.0170.03712.43
5.0.50.0170.02012.43
5.0.40.0100.02012.43
5.0.30.0170.03312.43
5.0.20.0130.02712.43
5.0.10.0100.04712.43
5.0.00.0200.05312.43
4.4.90.0130.01712.43
4.4.80.0130.03012.43
4.4.70.0100.02712.43
4.4.60.0130.03712.43
4.4.50.0170.03312.43
4.4.40.0070.02712.43
4.4.30.0170.01312.43
4.4.20.0130.02312.43
4.4.10.0100.01312.43
4.4.00.0130.05012.43
4.3.110.0200.01012.43
4.3.100.0170.02012.43
4.3.90.0130.01712.43
4.3.80.0170.04712.43
4.3.70.0100.02712.43
4.3.60.0100.01712.43
4.3.50.0170.01312.43
4.3.40.0200.04012.43
4.3.30.0070.02312.43
4.3.20.0070.03712.43
4.3.10.0030.02012.43
4.3.00.0030.03312.43

preferences:
39.92 ms | 401 KiB | 5 Q