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(); /*$parent = $this->xml->xpath('../'); $parent = $parent[0];*/ $target = $this->xml->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.60.0160.00318.80
8.3.50.0090.01221.39
8.3.40.0120.00319.46
8.3.30.0090.00619.18
8.3.20.0050.00319.49
8.3.10.0120.00321.47
8.3.00.0000.00822.15
8.2.180.0040.01117.13
8.2.170.0110.00422.96
8.2.160.0070.00720.85
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0110.00019.60
8.2.110.0030.00620.83
8.2.100.0040.00818.28
8.2.90.0030.00619.90
8.2.80.0000.00918.13
8.2.70.0060.00618.00
8.2.60.0000.00818.55
8.2.50.0060.00318.13
8.2.40.0030.00518.66
8.2.30.0060.00321.65
8.2.20.0000.00818.14
8.2.10.0000.00918.11
8.2.00.0030.00818.15
8.1.280.0150.00025.92
8.1.270.0070.00023.99
8.1.260.0060.00326.35
8.1.250.0080.00028.09
8.1.240.0000.01024.14
8.1.230.0110.00024.25
8.1.220.0000.00818.29
8.1.210.0000.00818.77
8.1.200.0060.00317.73
8.1.190.0060.00317.85
8.1.180.0040.00418.10
8.1.170.0060.00318.96
8.1.160.0080.00019.37
8.1.150.0050.00519.11
8.1.140.0000.00817.92
8.1.130.0000.00718.25
8.1.120.0000.00717.87
8.1.110.0050.00517.85
8.1.100.0040.00417.93
8.1.90.0000.00817.93
8.1.80.0000.00817.75
8.1.70.0000.00717.79
8.1.60.0090.00018.02
8.1.50.0000.00917.91
8.1.40.0050.00318.04
8.1.30.0040.00418.14
8.1.20.0060.00317.96
8.1.10.0060.00318.01
8.1.00.0090.00017.82
8.0.300.0050.00518.77
8.0.290.0040.00417.13
8.0.280.0070.00018.83
8.0.270.0040.00417.66
8.0.260.0000.00717.15
8.0.250.0050.00317.34
8.0.240.0120.00017.30
8.0.230.0000.00717.34
8.0.220.0040.00417.35
8.0.210.0090.00017.24
8.0.200.0000.00717.41
8.0.190.0060.00317.37
8.0.180.0040.00417.40
8.0.170.0000.00817.45
8.0.160.0040.00417.25
8.0.150.0030.00517.14
8.0.140.0000.00717.27
8.0.130.0070.00013.74
8.0.120.0080.00017.29
8.0.110.0030.00617.27
8.0.100.0020.00517.22
8.0.90.0050.00317.32
8.0.80.0030.01617.34
8.0.70.0040.00417.23
8.0.60.0040.00417.23
8.0.50.0040.00417.34
8.0.30.0140.00817.50
8.0.20.0100.00917.63
8.0.10.0000.00817.53
8.0.00.0090.00917.10
7.4.330.0020.00217.22
7.4.320.0040.00416.97
7.4.300.0000.00616.99
7.4.290.0050.00316.90
7.4.280.0050.00416.99
7.4.270.0030.00317.00
7.4.260.0000.00513.74
7.4.250.0040.00417.05
7.4.240.0000.00716.94
7.4.230.0030.00316.89
7.4.220.0130.00716.84
7.4.210.0070.00917.01
7.4.200.0070.00016.82
7.4.190.0000.00816.88
7.4.160.0110.01416.86
7.4.150.0060.01217.40
7.4.140.0100.00917.86
7.4.130.0060.01216.95
7.4.120.0090.00916.89
7.4.110.0120.00617.03
7.4.100.0110.00717.05
7.4.90.0140.01016.80
7.4.80.0040.01319.39
7.4.70.0070.01416.84
7.4.60.0040.01316.94
7.4.50.0080.00016.75
7.4.40.0080.00322.77
7.4.30.0060.01916.96
7.4.00.0070.00715.18
7.3.330.0030.00313.53
7.3.320.0070.00713.51
7.3.310.0030.00316.57
7.3.300.0000.00816.79
7.3.290.0090.00616.86
7.3.280.0050.01216.81
7.3.270.0070.01117.40
7.3.260.0130.00918.24
7.3.250.0100.00816.92
7.3.240.0080.00916.82
7.3.230.0130.00317.08
7.3.210.0090.00917.03
7.3.200.0120.00917.03
7.3.190.0120.00616.78
7.3.180.0080.00816.97
7.3.170.0070.01017.07
7.3.160.0030.01317.03
7.3.120.0090.00615.21
7.3.110.0140.00315.18
7.3.100.0070.01015.11
7.3.90.0090.00914.99
7.3.80.0000.01314.99
7.3.70.0090.00615.13
7.3.60.0070.00315.01
7.3.50.0030.01215.32
7.3.40.0030.01315.09
7.3.30.0030.01415.02
7.3.20.0090.00617.11
7.3.10.0090.00516.70
7.3.00.0130.00316.92
7.2.330.0160.00317.20
7.2.320.0090.00917.12
7.2.310.0070.01117.00
7.2.300.0060.01617.23
7.2.290.0070.01016.96
7.2.240.0040.01414.99
7.2.230.0040.01415.10
7.2.220.0070.00715.45
7.2.210.0000.01315.46
7.2.200.0070.00715.21
7.2.190.0060.00915.25
7.2.180.0030.01015.30
7.2.170.0030.00915.25
7.2.160.0000.01215.41
7.2.150.0040.00817.43
7.2.140.0080.00417.34
7.2.130.0090.00517.20
7.2.120.0030.01117.06
7.2.110.0030.01117.28
7.2.100.0030.01117.02
7.2.90.0050.00917.07
7.2.80.0090.00717.12
7.2.70.0040.01217.11
7.2.60.0080.00617.21
7.2.50.0060.00717.15
7.2.40.0080.00317.16
7.2.30.0050.00817.05
7.2.20.0030.00817.13
7.2.10.0090.00517.18
7.2.00.0080.00918.01
7.1.330.0090.00916.07
7.1.320.0030.01216.21
7.1.310.0040.01416.04
7.1.300.0070.01016.08
7.1.290.0090.00616.13
7.1.280.0070.01015.97
7.1.270.0080.00815.80
7.1.260.0040.01115.96
7.1.250.0030.00815.90
7.1.100.0040.00818.30
7.1.70.0020.00517.41
7.1.60.0000.01017.23
7.1.50.0160.00616.95
7.1.00.0000.03722.69
7.0.200.0000.01117.05
7.0.140.0070.07322.28
7.0.90.0000.06320.25
7.0.80.0100.08020.16
7.0.70.0130.06720.08
7.0.60.0100.05020.14
7.0.50.0070.09020.48
7.0.40.0070.07320.23
7.0.30.0070.09020.36
7.0.20.0000.06320.27
7.0.10.0030.09020.19
7.0.00.0070.08320.20
5.6.280.0030.07321.25
5.6.230.0100.06320.92
5.6.220.0130.05320.85
5.6.210.0170.07020.69
5.6.200.0130.07321.27
5.6.190.0070.08721.22
5.6.180.0100.08021.16
5.6.170.0100.05721.21
5.6.160.0100.08321.23
5.6.150.0100.08021.35
5.6.140.0130.08021.22
5.6.130.0070.07721.21
5.6.120.0100.05321.33
5.6.110.0070.07721.22
5.6.100.0170.07721.32
5.6.90.0070.07321.36
5.6.80.0070.05320.61
5.6.70.0130.07320.60
5.6.60.0100.07720.58
5.6.50.0170.06320.66
5.6.40.0030.08020.50
5.6.30.0100.07320.75
5.6.20.0100.08320.57
5.6.10.0070.07020.58
5.6.00.0130.07320.57
5.5.370.0100.05020.57
5.5.360.0130.06020.73
5.5.350.0070.05020.56
5.5.340.0030.04320.98
5.5.330.0030.08321.05
5.5.320.0070.08021.04
5.5.310.0100.04721.07
5.5.300.0030.04720.91
5.5.290.0030.06321.05
5.5.280.0030.08320.98
5.5.270.0070.04321.12
5.5.260.0130.08021.04
5.5.250.0100.08320.84
5.5.240.0000.08020.39
5.5.230.0030.08320.35
5.5.220.0100.09020.34
5.5.210.0070.07720.32
5.5.200.0030.04720.27
5.5.190.0130.07320.48
5.5.180.0000.05720.40
5.5.160.0070.05320.40
5.5.150.0070.06020.50
5.5.140.0070.07720.45
5.5.130.0030.06720.30
5.5.120.0130.07020.46
5.5.110.0170.06720.29
5.5.100.0070.04020.34
5.5.90.0070.08020.18
5.5.80.0070.06720.36
5.5.70.0100.08320.37
5.5.60.0030.08320.32
5.5.50.0030.08320.29
5.5.40.0070.07720.24
5.5.30.0070.06720.20
5.5.20.0100.03720.23
5.5.10.0030.05720.21
5.5.00.0100.07720.31
5.4.450.0130.07719.69
5.4.440.0070.08019.42
5.4.430.0200.07719.68
5.4.420.0000.06719.41
5.4.410.0130.07319.54
5.4.400.0070.07719.21
5.4.390.0070.06719.30
5.4.380.0170.06719.32
5.4.370.0070.04319.33
5.4.360.0100.07319.10
5.4.350.0100.05319.21
5.4.340.0130.07019.36
5.4.320.0030.04019.18
5.4.310.0070.07319.36
5.4.300.0100.07719.09
5.4.290.0030.08019.31
5.4.280.0130.07319.18
5.4.270.0030.08019.19
5.4.260.0130.07019.42
5.4.250.0030.05319.30
5.4.240.0100.06719.36
5.4.230.0130.04019.19
5.4.220.0030.05319.33
5.4.210.0100.07319.18
5.4.200.0070.04719.32
5.4.190.0000.05319.39
5.4.180.0100.03719.40
5.4.170.0100.07019.31
5.4.160.0100.03319.29
5.4.150.0100.06319.30
5.4.140.0100.06316.73
5.4.130.0070.06716.69
5.4.120.0070.04316.69
5.4.110.0170.06316.66
5.4.100.0030.04716.68
5.4.90.0030.04316.68
5.4.80.0000.04316.59
5.4.70.0030.03716.66
5.4.60.0130.06316.64
5.4.50.0000.07016.58
5.4.40.0100.07716.59
5.4.30.0100.06316.62
5.4.20.0170.04016.55
5.4.10.0100.03716.64
5.4.00.0100.04716.18
5.3.290.0130.06714.83
5.3.280.0000.07314.83
5.3.270.0030.08314.84
5.3.260.0070.03714.80
5.3.250.0030.07714.91
5.3.240.0070.07014.84
5.3.230.0030.06014.87
5.3.220.0030.04714.79
5.3.210.0100.07314.84
5.3.200.0100.06714.85
5.3.190.0070.03714.74
5.3.180.0030.03714.89
5.3.170.0200.05314.93
5.3.160.0030.05014.90
5.3.150.0070.07014.78
5.3.140.0070.04014.78
5.3.130.0070.08314.92
5.3.120.0100.07714.86
5.3.110.0070.07014.79
5.3.100.0100.06714.27
5.3.90.0100.06714.37
5.3.80.0100.06714.33
5.3.70.0000.07014.25
5.3.60.0070.03714.30
5.3.50.0070.05714.07
5.3.40.0030.08314.26
5.3.30.0100.06014.04
5.3.20.0100.05013.91
5.3.10.0030.04314.01
5.3.00.0070.07013.98
5.2.170.0070.06313.55
5.2.160.0030.04313.55
5.2.150.0030.05313.55
5.2.140.0030.03713.55
5.2.130.0030.06013.55
5.2.120.0000.04713.55
5.2.110.0170.05313.55
5.2.100.0070.06013.55
5.2.90.0100.05713.55
5.2.80.0000.07013.55
5.2.70.0070.03313.55
5.2.60.0030.04013.55
5.2.50.0070.06013.55
5.2.40.0030.06013.55
5.2.30.0030.05313.55
5.2.20.0030.06313.55
5.2.10.0070.05713.55
5.2.00.0000.04013.55
5.1.60.0070.04713.55
5.1.50.0030.05013.55
5.1.40.0070.04313.55
5.1.30.0030.04313.55
5.1.20.0030.05713.55
5.1.10.0070.04313.55
5.1.00.0030.03313.55
5.0.50.0000.04013.55
5.0.40.0030.04313.55
5.0.30.0000.06713.55
5.0.20.0070.03013.55
5.0.10.0000.04013.55
5.0.00.0030.06013.55
4.4.90.0000.02713.55
4.4.80.0030.02013.55
4.4.70.0070.03013.55
4.4.60.0070.03313.55
4.4.50.0100.03013.55
4.4.40.0000.04013.55
4.4.30.0030.03713.55
4.4.20.0030.01713.55
4.4.10.0000.02013.55
4.4.00.0000.02713.55
4.3.110.0000.03313.55
4.3.100.0000.02313.55
4.3.90.0070.03013.55
4.3.80.0000.04013.55
4.3.70.0070.02013.55
4.3.60.0000.03713.55
4.3.50.0100.03013.55
4.3.40.0030.04713.55
4.3.30.0000.02313.55
4.3.20.0000.03313.55
4.3.10.0000.03013.55
4.3.00.0000.03313.55

preferences:
40.8 ms | 401 KiB | 5 Q