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); var_dump($target);die; $target = $target[$offset]; return new self($target->asXML(), false); } 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'][1];

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.0150.00617.12
8.3.50.0130.01122.18
8.3.40.0160.00019.20
8.3.30.0060.00919.42
8.3.20.0040.00420.50
8.3.10.0080.00023.91
8.3.00.0040.00421.13
8.2.180.0070.00718.66
8.2.170.0110.00422.96
8.2.160.0070.00720.90
8.2.150.0080.00024.18
8.2.140.0120.00624.66
8.2.130.0120.00326.16
8.2.120.0040.00422.49
8.2.110.0030.00622.58
8.2.100.0040.00818.34
8.2.90.0030.00519.59
8.2.80.0040.00418.17
8.2.70.0030.00618.00
8.2.60.0030.00618.30
8.2.50.0030.00618.13
8.2.40.0030.00518.66
8.2.30.0030.00618.41
8.2.20.0080.00018.12
8.2.10.0080.00018.32
8.2.00.0000.00818.15
8.1.280.0090.01225.92
8.1.270.0000.00924.21
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0090.00024.04
8.1.230.0080.00319.65
8.1.220.0080.00018.00
8.1.210.0050.00318.77
8.1.200.0000.00917.85
8.1.190.0030.00518.02
8.1.180.0000.00818.10
8.1.170.0080.00419.02
8.1.160.0030.00622.46
8.1.150.0040.00418.96
8.1.140.0000.00817.83
8.1.130.0040.00418.14
8.1.120.0020.00517.72
8.1.110.0000.00817.92
8.1.100.0050.00217.80
8.1.90.0080.00017.95
8.1.80.0050.00317.70
8.1.70.0030.00317.80
8.1.60.0030.00617.85
8.1.50.0030.00517.93
8.1.40.0030.00517.80
8.1.30.0050.00317.82
8.1.20.0030.00618.07
8.1.10.0040.00417.99
8.1.00.0120.00017.93
8.0.300.0000.00718.77
8.0.290.0050.00217.68
8.0.280.0040.00418.86
8.0.270.0070.00017.64
8.0.260.0030.00317.25
8.0.250.0070.00017.41
8.0.240.0000.00717.30
8.0.230.0000.00717.36
8.0.220.0040.00417.25
8.0.210.0000.00717.45
8.0.200.0000.00617.28
8.0.190.0000.00817.45
8.0.180.0000.00717.46
8.0.170.0080.00017.40
8.0.160.0000.00717.47
8.0.150.0050.00317.27
8.0.140.0000.00717.23
8.0.130.0000.00613.79
8.0.120.0080.00017.39
8.0.110.0030.00517.33
8.0.100.0040.00417.34
8.0.90.0080.00017.29
8.0.80.0030.01317.45
8.0.70.0040.00417.28
8.0.60.0070.00017.27
8.0.50.0070.00017.22
8.0.30.0090.01017.63
8.0.20.0100.01117.40
8.0.10.0040.00417.51
8.0.00.0120.00717.29
7.4.330.0030.00315.00
7.4.320.0000.00717.06
7.4.300.0000.00717.02
7.4.290.0030.00316.89
7.4.280.0040.00417.04
7.4.270.0000.00717.05
7.4.260.0040.00416.98
7.4.250.0070.00016.95
7.4.240.0040.00416.99
7.4.230.0040.00316.95
7.4.220.0040.01416.98
7.4.210.0090.00717.04
7.4.200.0000.00716.95
7.4.190.0080.00017.10
7.4.160.0100.00716.81
7.4.150.0060.01217.40
7.4.140.0080.01417.86
7.4.130.0140.00517.03
7.4.120.0060.01016.96
7.4.110.0060.01217.04
7.4.100.0150.00616.88
7.4.90.0120.00616.87
7.4.80.0050.01119.39
7.4.70.0130.00416.78
7.4.60.0030.01216.98
7.4.50.0000.00816.98
7.4.40.0090.00622.77
7.4.30.0110.00716.95
7.4.00.0080.00815.38
7.3.330.0030.00213.88
7.3.320.0030.00313.82
7.3.310.0030.00316.68
7.3.300.0070.00016.86
7.3.290.0100.01016.85
7.3.280.0100.00816.84
7.3.270.0030.01317.40
7.3.260.0080.01417.03
7.3.250.0110.01116.98
7.3.240.0100.01016.81
7.3.230.0060.01016.80
7.3.210.0110.00716.77
7.3.200.0070.01019.39
7.3.190.0150.00317.01
7.3.180.0060.01116.83
7.3.170.0110.00616.94
7.3.160.0060.01016.91
7.3.120.0080.00615.11
7.3.110.0050.01115.09
7.3.100.0080.00614.97
7.3.90.0100.00515.10
7.3.80.0060.01015.03
7.3.70.0080.00314.99
7.3.60.0020.01214.96
7.3.50.0040.00615.15
7.3.40.0020.01115.10
7.3.30.0060.00615.02
7.3.20.0030.01216.93
7.3.10.0070.00816.86
7.3.00.0080.00616.75
7.2.330.0080.00816.93
7.2.320.0110.00816.91
7.2.310.0060.01216.98
7.2.300.0030.01317.13
7.2.290.0170.00617.18
7.2.250.0110.00715.11
7.2.240.0080.01015.32
7.2.230.0070.00815.08
7.2.220.0070.00515.01
7.2.210.0070.00715.33
7.2.200.0050.00915.23
7.2.190.0070.01015.17
7.2.180.0050.01015.21
7.2.170.0080.00715.11
7.2.160.0000.01715.25
7.2.150.0040.01116.71
7.2.140.0000.01316.96
7.2.130.0060.00917.04
7.2.120.0080.01016.81
7.2.110.0100.00516.90
7.2.100.0100.00517.14
7.2.90.0090.00917.04
7.2.80.0050.01016.75
7.2.70.0030.01317.04
7.2.60.0070.00716.95
7.2.50.0040.01016.93
7.2.40.0090.00617.04
7.2.30.0060.01017.09
7.2.20.0030.01016.82
7.2.10.0090.00617.00
7.2.00.0040.01118.00
7.1.330.0050.00916.07
7.1.320.0050.01115.94
7.1.310.0030.01115.98
7.1.300.0030.00916.05
7.1.290.0060.00815.92
7.1.280.0030.01015.94
7.1.270.0060.01015.93
7.1.260.0050.01015.94
7.1.250.0120.00715.93
7.1.200.0000.01316.06
7.1.101.1230.00716.14
7.1.70.0040.00417.28
7.1.60.0140.01019.29
7.1.50.0180.01117.04
7.1.00.0100.07022.54
7.0.200.0000.00816.79
7.0.140.0030.07322.25
7.0.60.0170.07320.28
7.0.50.0130.07318.16
7.0.40.0030.09020.48
7.0.30.0270.04720.38
7.0.20.0270.05320.48
7.0.10.0230.06020.31
7.0.00.0100.08720.33
5.6.280.0070.07021.11
5.6.210.0130.04721.00
5.6.200.0070.07318.44
5.6.190.0070.04020.70
5.6.180.0370.06020.85
5.6.170.0270.05720.87
5.6.160.0000.04320.66
5.6.150.0170.07018.38
5.6.140.0100.05018.43
5.6.130.0000.04718.49
5.6.120.0070.04321.28
5.6.110.0000.07721.22
5.6.100.0100.07721.14
5.6.90.0030.04321.12
5.6.80.0100.06320.69
5.6.70.0300.07320.71
5.5.350.0030.08020.63
5.5.340.0170.07018.23
5.5.330.0070.08320.69
5.5.320.0030.07720.56
5.5.310.0270.04020.49
5.5.300.0130.05318.16
5.5.290.0000.04318.09
5.5.280.0030.05320.94
5.5.270.0130.08020.99
5.5.260.0070.06021.01
5.5.250.0170.06720.78
5.5.240.0070.07020.50
5.4.450.0570.04719.79
5.4.440.0600.06319.86
5.4.430.0730.06319.85
5.4.420.0730.06719.61
5.4.410.0870.04719.52
5.4.400.0670.04719.54
5.4.390.0770.06319.21
5.4.380.0230.05718.64
5.4.370.0200.05018.95
5.4.360.0370.05018.98
5.4.350.0130.08318.98
5.4.340.0400.03718.97
5.4.320.0060.04412.80
5.4.310.0090.05112.80
5.4.300.0100.05512.80
5.4.290.0070.04212.79
5.4.280.0070.04112.69
5.4.270.0070.03812.70
5.4.260.0140.06512.70
5.4.250.0080.03712.69
5.4.240.0080.04312.69
5.4.230.0050.03812.68
5.4.220.0080.03512.68
5.4.210.0090.05212.68
5.4.200.0070.04012.68
5.4.190.0130.04412.66
5.4.180.0180.04012.67
5.4.170.0120.04812.68
5.4.160.0310.09112.68
5.4.150.0150.04512.68
5.4.140.0180.04012.35
5.4.130.0110.04612.34
5.4.120.0200.09712.30
5.4.110.0180.03812.29
5.4.100.0140.04312.30
5.4.90.0210.06812.30
5.4.80.0160.04312.30
5.4.70.0180.04012.29
5.4.60.0160.04012.30
5.4.50.0090.04912.30
5.4.40.0180.03812.29
5.4.30.0140.04312.28
5.4.20.0160.04112.29
5.4.10.0160.04212.28
5.4.00.0160.04011.76
5.3.290.0090.04113.06
5.3.280.0080.04412.99
5.3.270.0210.06912.98
5.3.260.0160.04412.98
5.3.250.0180.04212.98
5.3.240.0180.04212.98
5.3.230.0120.05112.97
5.3.220.0130.04812.94
5.3.210.0220.06812.94
5.3.200.0130.04612.93
5.3.190.0160.04512.94
5.3.180.0130.04612.94
5.3.170.0190.04012.93
5.3.160.0110.04912.94
5.3.150.0120.04712.94
5.3.140.0150.04312.93
5.3.130.0120.05112.93
5.3.120.0150.05012.92
5.3.110.0250.06812.92
5.3.100.0160.04612.41
5.3.90.0120.04612.39
5.3.80.0160.04412.38
5.3.70.0150.04412.38
5.3.60.0140.04512.36
5.3.50.0180.04112.31
5.3.40.0140.04412.31
5.3.30.0210.03612.27
5.3.20.0110.04612.05
5.3.10.0250.06012.02
5.3.00.0110.04512.01
5.2.170.0090.0379.52
5.2.160.0110.0359.51
5.2.150.0100.0369.52
5.2.140.0110.0359.51
5.2.130.0220.0549.47
5.2.120.0120.0349.47
5.2.110.0140.0369.47
5.2.100.0140.0369.48
5.2.90.0110.0369.47
5.2.80.0100.0379.46
5.2.70.0110.0369.46
5.2.60.0180.0589.42
5.2.50.0130.0339.39
5.2.40.0160.0309.37
5.2.30.0110.0359.34
5.2.20.0090.0379.33
5.2.10.0220.0549.23
5.2.00.0140.0319.09
5.1.60.0070.0328.37
5.1.50.0110.0298.37
5.1.40.0090.0318.36
5.1.30.0140.0288.71
5.1.20.0310.0728.59
5.1.10.0130.0298.17
5.1.00.0150.0268.17
5.0.50.0100.0236.66
5.0.40.0070.0246.51
5.0.30.0060.0376.32
5.0.20.0080.0236.30
5.0.10.0070.0266.27
5.0.00.0090.0366.27
4.4.90.0060.0194.78
4.4.80.0080.0174.75
4.4.70.0180.0374.75
4.4.60.0110.0164.75
4.4.50.0050.0214.77
4.4.40.0080.0304.71
4.4.30.0060.0214.76
4.4.20.0080.0174.84
4.4.10.0060.0194.85
4.4.00.0050.0324.76
4.3.110.0080.0184.67
4.3.100.0390.0484.66
4.3.90.0110.0144.64
4.3.80.0080.0324.58
4.3.70.0330.0554.63
4.3.60.0080.0194.63
4.3.50.0100.0174.63
4.3.40.0080.0294.54
4.3.30.0050.0213.30
4.3.20.0090.0153.27
4.3.10.0070.0163.24
4.3.00.0000.01314.49

preferences:
52.31 ms | 400 KiB | 5 Q