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)) { $tag = $this->xml->getName(); $target = $this->xml->xpath('../' . $tag); $target = $target[$offset]; return new self($target->asXML(), false); } if ('val' == $offset) { var_dump((array)$this->xml->$offset);die; } 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.40.0130.00919.17
8.3.30.0140.00419.18
8.3.20.0040.00420.46
8.3.10.0090.00022.18
8.3.00.0080.00022.64
8.2.170.0180.00422.96
8.2.160.0140.00721.33
8.2.150.0120.00324.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0030.00518.00
8.2.110.0030.00622.35
8.2.100.0120.00020.01
8.2.90.0000.00919.47
8.2.80.0000.00918.29
8.2.70.0040.00417.88
8.2.60.0030.00518.18
8.2.50.0030.00518.07
8.2.40.0080.00018.42
8.2.30.0000.00818.41
8.2.20.0000.00817.93
8.2.10.0090.00018.05
8.2.00.0040.00418.05
8.1.270.0040.00424.17
8.1.260.0030.00526.35
8.1.250.0090.00028.09
8.1.240.0060.00323.88
8.1.230.0070.00419.41
8.1.220.0040.00418.04
8.1.210.0030.00518.77
8.1.200.0030.00617.75
8.1.190.0050.00317.67
8.1.180.0050.00518.10
8.1.170.0110.00018.96
8.1.160.0040.00422.30
8.1.150.0000.00718.94
8.1.140.0050.00517.75
8.1.130.0030.00318.07
8.1.120.0040.00417.73
8.1.110.0040.00417.79
8.1.100.0070.00017.70
8.1.90.0040.00417.63
8.1.80.0000.00917.58
8.1.70.0000.00717.65
8.1.60.0030.00617.91
8.1.50.0000.00817.77
8.1.40.0080.00017.82
8.1.30.0040.00417.91
8.1.20.0040.00417.83
8.1.10.0050.00317.84
8.1.00.0000.00717.64
8.0.300.0040.00418.77
8.0.290.0040.00417.41
8.0.280.0030.00318.64
8.0.270.0030.00317.53
8.0.260.0070.00017.17
8.0.250.0070.00017.30
8.0.240.0000.00717.36
8.0.230.0040.00417.29
8.0.220.0000.00717.11
8.0.210.0030.00317.27
8.0.200.0030.00317.27
8.0.190.0000.00717.36
8.0.180.0040.00417.26
8.0.170.0050.00317.14
8.0.160.0060.00317.23
8.0.150.0030.00517.25
8.0.140.0070.00017.23
8.0.130.0060.00313.69
8.0.120.0040.00417.23
8.0.110.0040.00417.21
8.0.100.0030.00517.11
8.0.90.0040.00417.23
8.0.80.0100.00717.29
8.0.70.0000.00817.13
8.0.60.0040.00417.25
8.0.50.0000.00717.11
8.0.30.0060.01317.44
8.0.20.0080.01317.50
8.0.10.0050.00317.21
8.0.00.0090.00916.99
7.4.330.0050.00015.25
7.4.320.0000.00716.66
7.4.300.0030.00316.94
7.4.290.0080.00016.86
7.4.280.0070.00016.70
7.4.270.0000.00716.70
7.4.260.0000.00716.91
7.4.250.0000.00716.75
7.4.240.0060.00116.87
7.4.230.0050.00316.92
7.4.220.0030.01516.77
7.4.210.0050.01416.92
7.4.200.0000.00716.62
7.4.190.0000.00716.93
7.4.160.0100.00716.78
7.4.150.0040.01417.40
7.4.140.0090.01217.86
7.4.130.0090.00916.91
7.4.120.0110.00816.99
7.4.110.0080.00916.96
7.4.100.0130.00416.75
7.4.90.0120.00616.76
7.4.80.0140.00616.95
7.4.70.0030.01316.84
7.4.60.0120.00617.01
7.4.50.0000.00616.88
7.4.40.0120.00322.77
7.4.30.0070.01016.94
7.4.00.0040.01115.24
7.3.330.0000.00613.70
7.3.320.0000.00513.64
7.3.310.0050.00216.47
7.3.300.0040.00416.60
7.3.290.0100.00716.70
7.3.280.0080.01216.70
7.3.270.0190.00417.40
7.3.260.0130.01016.79
7.3.250.0160.00216.74
7.3.240.0100.01316.91
7.3.230.0040.01216.75
7.3.210.0120.00616.60
7.3.200.0140.01119.39
7.3.190.0150.00916.84
7.3.180.0120.00616.75
7.3.170.0060.00916.75
7.3.160.0090.00916.90
7.3.120.0030.01015.13
7.2.330.0040.01417.04
7.2.320.0140.00417.18
7.2.310.0090.00917.11
7.2.300.0140.00617.09
7.2.290.0070.01417.09
7.2.60.0120.00316.99
7.2.00.0000.01219.50
7.1.200.0000.01615.70
7.1.100.0030.01318.16
7.1.70.0000.00717.19
7.1.60.0090.01619.82
7.1.50.0090.00934.67
7.1.00.0070.07322.64
7.0.200.0060.00616.60
7.0.140.0100.06722.11
7.0.60.0070.04020.21
7.0.50.0100.04018.07
7.0.40.0130.08020.40
7.0.30.0270.05720.34
7.0.20.0400.07020.30
7.0.10.0000.08720.32
7.0.00.0070.03720.31
5.6.280.0100.06721.26
5.6.210.0130.08020.76
5.6.200.0070.08318.39
5.6.190.0100.07320.36
5.6.180.3030.04020.64
5.6.170.0100.05020.58
5.6.160.0030.05320.57
5.6.150.0130.03318.24
5.6.140.0070.07018.29
5.6.130.0000.08718.20
5.6.120.0030.04321.19
5.6.110.0100.03721.20
5.6.100.0170.07021.22
5.6.90.0100.07721.20
5.6.80.0070.07720.60
5.5.350.0070.04020.59
5.5.340.0100.07718.19
5.5.330.0030.08020.55
5.5.320.0270.06720.35
5.5.310.0330.07320.40
5.5.300.0030.07318.00
5.5.290.0070.05018.11
5.5.280.0070.08320.90
5.5.270.0170.07320.93
5.5.260.0130.08021.07
5.5.250.0100.07720.68
5.5.240.0170.05020.36
5.4.450.0430.06019.70
5.4.440.0170.08719.79
5.4.430.0230.05319.63
5.4.420.0130.06019.53
5.4.410.0230.04719.14
5.4.400.0270.06018.93
5.4.390.0030.06318.82
5.4.380.0130.06318.78
5.4.370.0330.04718.86
5.4.360.0270.05318.54
5.4.350.0470.05318.84
5.4.340.0330.05718.63
5.4.320.0090.03712.70
5.4.310.0100.03912.69
5.4.300.0080.05212.70
5.4.290.0060.03912.70
5.4.280.0040.04812.59
5.4.270.0160.07212.59
5.4.260.0070.04512.59
5.4.250.0070.05112.59
5.4.240.0070.04112.59
5.4.230.0070.04312.58
5.4.220.0060.05312.58
5.4.210.0080.04012.58
5.4.200.0140.05312.59
5.4.190.0160.04212.56
5.4.180.0140.04312.57
5.4.170.0170.04012.57
5.4.160.0110.04712.58
5.4.150.0150.04512.57
5.4.140.0120.04512.25
5.4.130.0250.06312.24
5.4.120.0190.03712.20
5.4.110.0150.04112.20
5.4.100.0150.04312.20
5.4.90.0120.05012.20
5.4.80.0180.04212.20
5.4.70.0190.03912.19
5.4.60.0290.08712.19
5.4.50.0160.04012.20
5.4.40.0180.03912.18
5.4.30.0120.04512.18
5.4.20.0220.06412.18
5.4.10.0130.04312.18
5.4.00.0160.03911.66
5.3.290.0080.04312.95
5.3.280.0080.04212.88
5.3.270.0130.04712.88
5.3.260.0160.04412.88
5.3.250.0130.04812.88
5.3.240.0320.08812.88
5.3.230.0190.04112.87
5.3.220.0210.03912.84
5.3.210.0120.04812.84
5.3.200.0170.04312.84
5.3.190.0170.04612.84
5.3.180.0190.07012.84
5.3.170.0160.04412.84
5.3.160.0160.04212.84
5.3.150.0160.04312.84
5.3.140.0180.04112.82
5.3.130.0130.04812.82
5.3.120.0150.04512.82
5.3.110.0140.04512.82
5.3.100.0130.04612.31
5.3.90.0160.04212.29
5.3.80.0180.04112.28
5.3.70.0270.06212.28
5.3.60.0150.04412.26
5.3.50.0200.03912.21
5.3.40.0160.04212.21
5.3.30.0140.04312.17
5.3.20.0170.04011.95
5.3.10.0140.04111.92
5.3.00.0160.03911.91
5.2.170.0110.0369.40
5.2.160.0100.0369.41
5.2.150.0120.0359.41
5.2.140.0150.0329.40
5.2.130.0150.0319.36
5.2.120.0150.0319.36
5.2.110.0100.0379.36
5.2.100.0170.0319.37
5.2.90.0260.0509.36
5.2.80.0090.0379.36
5.2.70.0080.0389.36
5.2.60.0110.0359.31
5.2.50.0100.0369.28
5.2.40.0150.0319.25
5.2.30.0130.0349.23
5.2.20.0130.0349.22
5.2.10.0100.0369.13
5.2.00.0120.0328.99
5.1.60.0120.0278.28
5.1.50.0200.0508.27
5.1.40.0100.0298.26
5.1.30.0140.0588.61
5.1.20.0120.0308.59
5.1.10.0080.0348.17
5.1.00.0100.0318.17
5.0.50.0130.0206.66
5.0.40.0100.0226.51
5.0.30.0080.0376.33
5.0.20.0070.0256.30
5.0.10.0090.0216.27
5.0.00.0050.0386.26
4.4.90.0060.0184.78
4.4.80.0050.0194.76
4.4.70.0070.0184.76
4.4.60.0170.0384.76
4.4.50.0050.0204.77
4.4.40.0090.0264.71
4.4.30.0060.0194.75
4.4.20.0100.0154.84
4.4.10.0070.0174.85
4.4.00.0070.0284.75
4.3.110.0090.0154.67
4.3.100.0090.0154.66
4.3.90.0050.0184.64
4.3.80.0070.0274.59
4.3.70.0070.0164.63
4.3.60.0080.0164.63
4.3.50.0050.0194.63
4.3.40.0090.0244.54
4.3.30.0070.0173.30
4.3.20.0060.0183.28
4.3.10.0040.0193.24
4.3.00.0070.0207.28

preferences:
37.77 ms | 400 KiB | 5 Q