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('..'); var_dump($target[1]);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.0100.01018.93
8.3.50.0060.01122.24
8.3.40.0080.00819.17
8.3.30.0120.00619.22
8.3.20.0050.00319.27
8.3.10.0050.00321.60
8.3.00.0040.00424.17
8.2.180.0130.00617.00
8.2.170.0150.00322.96
8.2.160.0000.01420.93
8.2.150.0030.00624.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0090.00021.56
8.2.110.0090.00020.83
8.2.100.0080.00418.34
8.2.90.0040.00419.42
8.2.80.0080.00018.30
8.2.70.0060.00318.25
8.2.60.0060.00318.30
8.2.50.0050.00518.07
8.2.40.0040.00418.53
8.2.30.0040.00421.57
8.2.20.0040.00418.21
8.2.10.0000.00818.27
8.2.00.0030.00718.14
8.1.280.0120.00325.92
8.1.270.0040.00423.99
8.1.260.0070.00426.35
8.1.250.0000.00828.09
8.1.240.0070.00322.82
8.1.230.0090.00321.46
8.1.220.0000.00918.77
8.1.210.0000.00919.40
8.1.200.0060.00317.73
8.1.190.0000.00818.01
8.1.180.0060.00318.10
8.1.170.0040.00419.07
8.1.160.0080.00019.25
8.1.150.0000.00719.03
8.1.140.0040.00417.89
8.1.130.0030.00318.13
8.1.120.0000.00717.94
8.1.110.0060.00317.70
8.1.100.0000.00717.86
8.1.90.0000.00817.93
8.1.80.0060.00317.68
8.1.70.0000.00717.94
8.1.60.0030.00618.02
8.1.50.0040.00417.70
8.1.40.0040.00417.96
8.1.30.0000.00818.05
8.1.20.0060.00317.97
8.1.10.0050.00318.05
8.1.00.0000.00817.80
8.0.300.0030.00520.39
8.0.290.0080.00017.43
8.0.280.0070.00018.96
8.0.270.0050.00317.62
8.0.260.0000.00717.20
8.0.250.0080.00017.47
8.0.240.0000.00817.37
8.0.230.0050.00317.47
8.0.220.0040.00417.25
8.0.210.0000.00717.46
8.0.200.0000.00917.38
8.0.190.0000.00817.37
8.0.180.0050.00317.21
8.0.170.0040.00417.23
8.0.160.0030.00517.24
8.0.150.0030.00517.34
8.0.140.0030.00617.20
8.0.130.0000.00613.77
8.0.120.0080.00017.37
8.0.110.0000.00817.45
8.0.100.0000.00817.34
8.0.90.0000.00817.34
8.0.80.0000.01517.34
8.0.70.0040.00417.29
8.0.60.0000.00717.37
8.0.50.0040.00417.33
8.0.30.0170.00517.44
8.0.20.0120.01117.62
8.0.10.0050.00217.41
8.0.00.0090.00917.24
7.4.330.0050.00015.01
7.4.320.0030.00316.89
7.4.300.0040.00417.06
7.4.290.0070.00016.91
7.4.280.0030.00316.93
7.4.270.0070.00017.02
7.4.260.0000.00513.69
7.4.250.0040.00417.03
7.4.240.0040.00416.88
7.4.230.0000.00716.80
7.4.220.0100.00716.82
7.4.210.0080.00617.03
7.4.200.0040.00416.81
7.4.190.0050.00316.87
7.4.160.0060.00916.93
7.4.150.0180.00017.40
7.4.140.0070.01017.86
7.4.130.0130.01216.90
7.4.120.0060.01317.17
7.4.110.0140.00417.03
7.4.100.0150.00617.07
7.4.90.0030.01516.96
7.4.80.0150.00919.39
7.4.70.0130.00316.88
7.4.60.0080.00816.89
7.4.50.0090.00016.99
7.4.40.0070.00622.52
7.4.30.0070.01016.98
7.4.10.0100.00715.48
7.4.00.0080.01015.16
7.3.330.0000.00513.81
7.3.320.0000.00613.88
7.3.310.0030.00616.93
7.3.300.0040.00416.88
7.3.290.0040.01216.87
7.3.280.0080.01016.84
7.3.270.0100.01017.40
7.3.260.0090.01018.24
7.3.250.0050.01316.98
7.3.240.0100.00716.95
7.3.230.0090.01016.91
7.3.210.0130.00316.81
7.3.200.0120.01119.39
7.3.190.0000.01616.92
7.3.180.0060.01217.08
7.3.170.0090.00916.88
7.3.160.0110.00617.07
7.3.130.0090.00615.20
7.3.120.0070.01215.08
7.3.110.0000.01514.99
7.3.100.0070.00715.24
7.3.90.0070.01114.97
7.3.80.0060.00615.02
7.3.70.0090.00015.31
7.3.60.0080.00014.93
7.3.50.0040.00414.93
7.3.40.0060.00615.12
7.3.30.0000.00915.00
7.3.20.0030.01016.96
7.3.10.0040.00416.70
7.3.00.0080.00616.85
7.2.330.0100.01017.07
7.2.320.0060.01516.87
7.2.310.0080.01516.98
7.2.300.0100.00617.09
7.2.290.0140.00417.21
7.2.260.0100.00615.39
7.2.250.0070.01115.61
7.2.240.0060.00915.42
7.2.230.0100.00715.24
7.2.220.0040.01115.30
7.2.210.0060.00915.22
7.2.200.0030.01015.12
7.2.190.0040.01115.16
7.2.180.0040.00715.29
7.2.170.0030.01015.21
7.2.160.0060.00315.49
7.2.150.0070.01117.38
7.2.140.0000.01317.04
7.2.130.0090.00617.15
7.2.120.0060.00917.04
7.2.110.0120.00317.21
7.2.100.0050.01116.99
7.2.90.0020.01217.25
7.2.80.0050.01216.98
7.2.70.0090.00517.04
7.2.60.0050.00917.04
7.2.50.0050.00717.22
7.2.40.0030.01017.04
7.2.30.0020.01117.00
7.2.20.0100.00117.19
7.2.10.0070.00517.13
7.2.00.0060.00717.99
7.1.330.0000.01215.90
7.1.320.0040.00416.02
7.1.310.0060.00615.91
7.1.300.0060.00615.91
7.1.290.0040.00415.79
7.1.280.0000.01115.81
7.1.270.0030.00716.13
7.1.260.0100.00315.94
7.1.250.0080.00816.06
7.1.240.0090.00916.13
7.1.230.0050.00615.79
7.1.220.0070.00716.01
7.1.210.0030.01115.88
7.1.200.0090.00715.96
7.1.190.0030.01015.85
7.1.180.0050.01016.04
7.1.170.0060.00715.87
7.1.160.0040.01016.09
7.1.150.0070.00315.97
7.1.140.0040.00916.06
7.1.130.0020.01116.06
7.1.120.0040.00715.93
7.1.110.0040.01016.01
7.1.100.0050.00916.69
7.1.90.0040.00615.85
7.1.80.0050.00415.94
7.1.70.0040.00516.44
7.1.60.0080.00917.12
7.1.50.0070.01216.43
7.1.40.0050.00816.06
7.1.30.0070.00715.83
7.1.20.0020.00815.95
7.1.10.0140.00015.82
7.1.00.0070.01618.11
7.0.330.0070.00915.43
7.0.320.0040.00715.52
7.0.310.0070.00715.65
7.0.300.0070.00515.49
7.0.290.0070.00415.65
7.0.280.0070.00615.62
7.0.270.0060.00415.74
7.0.260.0040.00715.51
7.0.250.0080.00515.83
7.0.240.0030.00715.73
7.0.230.0040.00715.72
7.0.220.0060.00715.57
7.0.210.0090.00515.71
7.0.200.0050.00816.07
7.0.190.0030.00715.61
7.0.180.0020.01115.58
7.0.170.0030.00615.76
7.0.160.0080.00515.72
7.0.150.0070.00715.71
7.0.140.0070.02717.86
7.0.130.0110.00215.61
7.0.120.0030.00815.48
7.0.110.0050.00715.74
7.0.100.0080.03017.13
7.0.90.0040.02117.25
7.0.80.0070.02717.03
7.0.70.0030.03217.12
7.0.60.0040.02117.17
7.0.50.0080.02117.26
7.0.40.0050.02115.77
7.0.30.0080.02015.86
7.0.20.0080.02715.96
7.0.10.0080.03015.98
7.0.00.0080.03115.90
5.6.400.0000.00914.52
5.6.390.0110.00314.62
5.6.380.0110.00514.66
5.6.370.0030.00814.71
5.6.360.0050.00714.46
5.6.350.0070.00714.54
5.6.340.0080.00514.52
5.6.330.0090.00314.77
5.6.320.0050.00814.87
5.6.310.0070.00714.74
5.6.300.0100.00314.60
5.6.290.0050.00514.84
5.6.280.0040.02816.78
5.6.270.0080.00514.72
5.6.260.0030.01114.61
5.6.250.0090.03216.72
5.6.240.0130.02316.56
5.6.230.0120.03116.81
5.6.220.0080.02316.67
5.6.210.0080.03416.74
5.6.200.0070.03116.80
5.6.190.0070.03216.88
5.6.180.0070.02216.76
5.6.170.0060.02316.98
5.6.160.0060.01616.72
5.6.150.0080.01716.74
5.6.140.0080.01816.97
5.6.130.0070.02916.77
5.6.120.0070.03416.87
5.6.110.0080.03216.86
5.6.100.0070.03416.78
5.6.90.0080.02116.65
5.6.80.0070.03116.62
5.6.70.0120.02316.48
5.6.60.0090.03016.59
5.6.50.0100.02316.49
5.6.40.0070.02816.54
5.6.30.0080.02216.68
5.6.20.0030.03316.48
5.6.10.0080.03216.61
5.6.00.0050.02616.54
5.5.380.0080.02215.54
5.5.370.0100.01915.49
5.5.360.0050.03215.41
5.5.350.0060.03215.48
5.5.340.0110.01515.54
5.5.330.0070.02615.69
5.5.320.0050.02015.71
5.5.310.0040.02815.68
5.5.300.0040.02915.68
5.5.290.0060.03315.65
5.5.280.0060.03015.63
5.5.270.0050.03215.70
5.5.260.0070.03315.40
5.5.250.0120.02615.65
5.5.240.0070.01915.37
5.5.230.0040.02015.42
5.5.220.0050.01815.44
5.5.210.0120.01515.50
5.5.200.0060.03315.35
5.5.190.0050.02915.46
5.5.180.0080.02315.32
5.5.170.0040.00412.92
5.5.160.0090.01715.41
5.5.150.0010.03515.45
5.5.140.0050.03315.38
5.5.130.0080.02215.38
5.5.120.0090.02715.44
5.5.110.0070.03015.27
5.5.100.0040.01915.27
5.5.90.0090.02515.39
5.5.80.0080.02415.35
5.5.70.0090.01815.40
5.5.60.0060.02715.31
5.5.50.0060.03015.31
5.5.40.0030.02715.38
5.5.30.0090.02315.35
5.5.20.0050.02815.31
5.5.10.0050.03215.25
5.5.00.0060.02315.23
5.4.450.0030.03114.02
5.4.440.0050.02513.99
5.4.430.0030.03414.06
5.4.420.0040.03013.95
5.4.410.0090.02714.02
5.4.400.0100.01413.83
5.4.390.0040.01913.80
5.4.380.0060.01713.97
5.4.370.0050.02213.86
5.4.360.0040.02113.85
5.4.350.0050.02613.89
5.4.340.0060.01713.85
5.4.330.0000.00911.11
5.4.320.0060.01713.89
5.4.310.0050.01813.89
5.4.300.0010.03013.99
5.4.290.0040.02913.96
5.4.280.0040.01813.93
5.4.270.0050.02914.01
5.4.260.0050.01513.86
5.4.250.0020.01913.98
5.4.240.0070.01713.86
5.4.230.0020.01713.85
5.4.220.0060.02013.81
5.4.210.0020.02613.78
5.4.200.0060.02713.83
5.4.190.0070.02213.82
5.4.180.0020.02713.84
5.4.170.0080.01513.80
5.4.160.0040.02113.86
5.4.150.0100.01413.93
5.4.140.0040.01912.86
5.4.130.0040.01913.03
5.4.120.0070.02313.03
5.4.110.0060.01512.99
5.4.100.0060.02513.02
5.4.90.0040.01613.03
5.4.80.0070.01812.90
5.4.70.0110.01813.07
5.4.60.0070.02512.97
5.4.50.0050.02113.01
5.4.40.0050.02812.91
5.4.30.0060.02612.97
5.4.20.0050.02112.99
5.4.10.0100.02613.12
5.4.00.0060.02512.84
5.3.290.0100.02312.31
5.3.280.0060.01812.33
5.3.270.0080.01612.28
5.3.260.0050.02812.22
5.3.250.0030.01912.28
5.3.240.0060.02912.15
5.3.230.0090.02712.24
5.3.220.0090.02312.18
5.3.210.0030.02112.28
5.3.200.0040.03112.19
5.3.190.0080.01912.21
5.3.180.0050.03312.27
5.3.170.0030.01812.34
5.3.160.0030.02812.29
5.3.150.0050.02612.22
5.3.140.0060.01512.21
5.3.130.0080.02912.24
5.3.120.0050.02512.27
5.3.110.0030.03012.24
5.3.100.0070.01912.04
5.3.90.0060.02612.13
5.3.80.0070.02512.00
5.3.70.0060.02612.07
5.3.60.0040.02511.97
5.3.50.0070.02012.00
5.3.40.0040.03011.95
5.3.30.0010.03112.02
5.3.20.0110.01311.99
5.3.10.0040.02311.84
5.3.00.0090.01811.79
5.2.170.0020.03410.70
5.2.160.0040.01810.73
5.2.150.0040.01910.67
5.2.140.0040.03010.72
5.2.130.0050.02310.59
5.2.120.0050.01510.68
5.2.110.0040.02510.70
5.2.100.0020.02010.70
5.2.90.0030.03110.64
5.2.80.0060.01510.64
5.2.70.0030.03510.64
5.2.60.0020.02510.61
5.2.50.0040.01810.60
5.2.40.0060.03010.58
5.2.30.0020.03610.63
5.2.20.0030.03310.57
5.2.10.0020.03910.59
5.2.00.0050.03310.45
5.1.60.0040.02410.09
5.1.50.0020.02710.10
5.1.40.0010.03110.06
5.1.30.0060.02710.26
5.1.20.0060.03010.25
5.1.10.0030.02510.04
5.1.00.0050.02310.02
5.0.50.0040.0189.32
5.0.40.0030.0159.24
5.0.30.0050.0299.05
5.0.20.0030.0189.15
5.0.10.0020.0269.14
5.0.00.0050.0319.07
4.4.90.0020.0238.92
4.4.80.0000.0228.92
4.4.70.0020.0208.92
4.4.60.0000.0128.92
4.4.50.0030.0188.92
4.4.40.0010.0258.92
4.4.30.0030.0118.92
4.4.20.0040.0108.92
4.4.10.0000.0128.92
4.4.00.0000.0328.92
4.3.110.0020.0188.92
4.3.100.0030.0158.92
4.3.90.0010.0138.92
4.3.80.0050.0198.92
4.3.70.0030.0178.92
4.3.60.0030.0148.92
4.3.50.0030.0128.92
4.3.40.0020.0178.92
4.3.30.0000.0208.92
4.3.20.0020.0178.92
4.3.10.0000.0198.92
4.3.00.0000.0128.92

preferences:
44.01 ms | 401 KiB | 5 Q