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)) { die('potato'); $tag = $this->xml->getName(); $parent = $this->xml->xpath('../'); $parent = $parent[0]; $target = $parent->xpath($tag . '[' . $offset . ']'); $target = $target[0]; 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']; var_dump($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.70.0030.02017.25
8.3.60.0110.00818.65
8.3.50.0070.00922.11
8.3.40.0180.00319.27
8.3.30.0140.00419.23
8.3.20.0060.00318.89
8.3.10.0090.00020.91
8.3.00.0040.00423.61
8.2.180.0040.01116.88
8.2.170.0060.00922.96
8.2.160.0040.01120.72
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0000.00819.78
8.2.110.0090.00020.76
8.2.100.0040.00818.22
8.2.90.0030.00519.40
8.2.80.0030.00518.30
8.2.70.0000.00817.88
8.2.60.0000.00818.18
8.2.50.0040.00418.07
8.2.40.0040.00418.47
8.2.30.0050.00618.43
8.2.20.0020.00518.05
8.2.10.0040.00418.04
8.2.00.0080.00018.18
8.1.280.0200.00025.92
8.1.270.0040.00823.99
8.1.260.0060.01326.35
8.1.250.0080.00028.09
8.1.240.0030.00622.86
8.1.230.0080.00321.34
8.1.220.0000.00818.77
8.1.210.0000.00819.43
8.1.200.0100.00017.60
8.1.190.0050.00317.89
8.1.180.0040.00418.10
8.1.170.0050.00318.84
8.1.160.0070.00019.20
8.1.150.0030.00518.95
8.1.140.0040.00417.82
8.1.130.0030.00518.15
8.1.120.0030.00517.80
8.1.110.0040.00417.65
8.1.100.0040.00417.77
8.1.90.0040.00417.69
8.1.80.0000.00817.78
8.1.70.0000.00717.68
8.1.60.0030.00617.92
8.1.50.0060.00317.85
8.1.40.0000.00817.85
8.1.30.0040.00417.80
8.1.20.0040.00417.92
8.1.10.0000.00717.90
8.1.00.0030.00517.70
8.0.300.0070.00020.13
8.0.290.0060.00317.54
8.0.280.0030.00318.69
8.0.270.0050.00317.42
8.0.260.0000.00817.25
8.0.250.0040.00417.30
8.0.240.0100.00017.27
8.0.230.0040.00417.29
8.0.220.0030.00317.13
8.0.210.0040.00417.21
8.0.200.0000.00717.29
8.0.190.0000.00717.27
8.0.180.0030.00517.25
8.0.170.0040.00417.26
8.0.160.0040.00417.34
8.0.150.0000.00917.17
8.0.140.0060.00317.09
8.0.130.0000.00613.66
8.0.120.0000.00817.13
8.0.110.0040.00417.28
8.0.100.0080.00217.15
8.0.90.0000.00917.14
8.0.80.0030.01317.20
8.0.70.0050.00217.30
8.0.60.0080.00017.07
8.0.50.0040.00417.22
8.0.30.0100.00917.46
8.0.20.0120.00717.44
8.0.10.0030.00517.25
8.0.00.0110.00716.99
7.4.330.0050.00014.93
7.4.320.0060.00016.82
7.4.300.0000.00716.95
7.4.290.0000.00716.96
7.4.280.0030.00516.73
7.4.270.0000.00816.76
7.4.260.0050.00013.65
7.4.250.0040.00416.91
7.4.240.0030.00316.91
7.4.230.0050.00316.98
7.4.220.0140.00416.77
7.4.210.0050.01116.77
7.4.200.0000.00816.86
7.4.190.0000.00716.94
7.4.160.0140.01016.74
7.4.150.0130.00617.40
7.4.140.0090.00917.86
7.4.130.0070.01016.98
7.4.120.0060.01216.71
7.4.110.0100.00716.83
7.4.100.0000.01717.09
7.4.90.0070.01016.90
7.4.80.0090.00919.04
7.4.70.0140.00616.83
7.4.60.0130.00316.77
7.4.50.0000.00617.06
7.4.40.0120.00322.27
7.4.30.0140.00716.93
7.4.00.0030.01315.06
7.3.330.0000.00513.68
7.3.320.0030.00313.51
7.3.310.0050.00216.60
7.3.300.0040.00416.64
7.3.290.0090.00616.72
7.3.280.0060.01116.70
7.3.270.0090.00917.40
7.3.260.0080.01518.24
7.3.250.0150.00516.81
7.3.240.0150.00616.69
7.3.230.0100.00716.82
7.3.210.0070.01016.71
7.3.200.0070.01619.39
7.3.190.0150.00316.62
7.3.180.0120.00416.69
7.3.170.0060.00916.75
7.3.160.0090.00616.85
7.3.120.0060.01215.20
7.3.10.0100.00616.83
7.3.00.0080.00816.73
7.2.330.0070.01017.08
7.2.320.0120.01216.98
7.2.310.0140.00716.75
7.2.300.0080.00817.09
7.2.290.0100.00616.93
7.2.130.0140.00617.07
7.2.120.0090.00617.09
7.2.110.0060.00917.15
7.2.100.0030.00817.16
7.2.90.0090.00417.05
7.2.80.0030.01316.97
7.2.70.0030.01317.02
7.2.60.0090.00317.27
7.2.50.0110.00717.16
7.2.40.0170.00016.84
7.2.30.0180.00917.05
7.2.20.0040.01816.96
7.2.10.0070.00716.73
7.2.00.0020.00918.41
7.1.250.0000.01616.05
7.1.100.0000.01418.41
7.1.70.0040.00417.26
7.1.60.0100.01319.40
7.1.50.0040.01517.19
7.1.00.0000.03722.60
7.0.200.0000.00817.08
7.0.140.0000.07722.17
7.0.60.0170.07020.21
7.0.50.0030.04018.02
7.0.40.0070.04020.18
7.0.30.0170.08020.29
7.0.20.0270.08020.54
7.0.10.0270.05020.32
7.0.00.0030.05720.25
5.6.280.0070.07021.09
5.6.210.0130.06320.70
5.6.200.0070.09018.36
5.6.190.0070.04020.51
5.6.180.0400.05720.61
5.6.170.0470.08020.64
5.6.160.0100.08320.61
5.6.150.0070.07718.35
5.6.140.0100.07018.27
5.6.130.0030.04018.34
5.6.120.0170.06321.21
5.6.110.0130.07021.09
5.6.100.0100.08321.22
5.6.90.0070.07321.14
5.6.80.0000.05720.61
5.6.70.0330.07320.63
5.5.350.3470.04020.56
5.5.340.0000.04718.18
5.5.330.0030.05720.59
5.5.320.0370.04320.58
5.5.310.0370.07320.48
5.5.300.0070.03718.18
5.5.290.0030.08318.04
5.5.280.0100.06020.95
5.5.270.0070.05321.04
5.5.260.0030.08720.86
5.5.250.0130.08720.69
5.5.240.0130.06020.44
5.4.450.0270.05719.64
5.4.440.0330.03319.55
5.4.430.0270.06019.62
5.4.420.0270.07719.44
5.4.410.0400.03319.34
5.4.400.0230.07319.09
5.4.390.0170.07719.33
5.4.380.0170.07319.31
5.4.370.0300.06719.38
5.4.360.0300.06719.39
5.4.350.0230.04319.33
5.4.340.0230.04019.09
5.4.320.0230.07319.30
5.4.310.0270.03319.15
5.4.300.0400.06319.15
5.4.290.0300.07019.37
5.4.280.0200.05019.14
5.4.270.0270.05719.17
5.4.260.0330.06719.10
5.4.250.0200.06019.14
5.4.240.0330.06319.17
5.4.230.0270.07019.16
5.4.220.0300.04019.05
5.4.210.0300.06719.17
5.4.200.0200.06019.30
5.4.190.0130.05019.09
5.4.180.0300.07019.34
5.4.170.0230.06019.34
5.4.160.0270.07019.16
5.4.150.0230.05019.13
5.4.140.0270.06316.61
5.4.130.0230.06016.51
5.4.120.0300.04016.61
5.4.110.0200.08016.57
5.4.100.0230.06716.70
5.4.90.0200.06316.69
5.4.80.0270.06316.72
5.4.70.0270.06016.66
5.4.60.0270.07016.52
5.4.50.0270.06316.67
5.4.40.0300.06716.67
5.4.30.0200.06716.36
5.4.20.0300.06716.51
5.4.10.0230.06016.67
5.4.00.0270.04315.96
5.3.290.0300.06714.88
5.3.280.0300.07314.68
5.3.270.0270.05314.83
5.3.260.0270.04014.93
5.3.250.0300.05314.68
5.3.240.0300.04314.68
5.3.230.0270.06314.68
5.3.220.0330.04714.69
5.3.210.0230.05714.76
5.3.200.0300.06714.90
5.3.190.0300.06714.80
5.3.180.0070.06014.90
5.3.170.0400.06014.66
5.3.160.0200.06714.75
5.3.150.0200.07714.75
5.3.140.0330.04314.84
5.3.130.0370.05314.66
5.3.120.0230.06714.78
5.3.110.0270.06714.64
5.3.100.0300.05314.37
5.3.90.0270.06714.09
5.3.80.0270.06314.04
5.3.70.0270.06714.24
5.3.60.0200.05314.20
5.3.50.0330.06014.28
5.3.40.0270.05714.06
5.3.30.0330.06314.14
5.3.20.0300.05313.98
5.3.10.0270.06313.73
5.3.00.0330.05713.68
5.2.170.0230.03312.39
5.2.160.0200.06012.39
5.2.150.0130.04012.39
5.2.140.0300.05012.40
5.2.130.0170.06712.41
5.2.120.0200.06012.42
5.2.110.0170.05312.43
5.2.100.0170.06012.43
5.2.90.0130.04012.43
5.2.80.0130.04012.43
5.2.70.0130.04712.46
5.2.60.0230.05312.46
5.2.50.0230.05312.46
5.2.40.0170.04712.46
5.2.30.0070.04712.46
5.2.20.0130.05712.46
5.2.10.0270.04312.46
5.2.00.0130.06312.46
5.1.60.0300.03712.46
5.1.50.0170.05312.46
5.1.40.0130.04712.46
5.1.30.0130.04312.46
5.1.20.0230.04312.46
5.1.10.0200.03012.46
5.1.00.0130.03312.46
5.0.50.0070.04312.46
5.0.40.0130.03012.46
5.0.30.0030.04712.46
5.0.20.0070.03012.46
5.0.10.0170.02312.46
5.0.00.0070.05312.46
4.4.90.0130.03012.46
4.4.80.0130.02712.46
4.4.70.0100.03012.46
4.4.60.0100.02712.46
4.4.50.0070.03312.46
4.4.40.0100.05312.46
4.4.30.0130.02012.46
4.4.20.0170.03012.46
4.4.10.0100.01312.46
4.4.00.0100.05012.46
4.3.110.0070.02312.46
4.3.100.0030.03312.46
4.3.90.0100.03312.46
4.3.80.0070.06012.46
4.3.70.0100.03012.46
4.3.60.0070.03712.46
4.3.50.0200.01012.46
4.3.40.0130.04712.46
4.3.30.0030.02312.46
4.3.20.0070.03312.46
4.3.10.0030.02712.46
4.3.00.0100.01312.46

preferences:
37.49 ms | 401 KiB | 5 Q