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 = $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.60.0090.00618.80
8.3.50.0140.00422.26
8.3.40.0040.01119.46
8.3.30.0030.01219.51
8.3.20.0080.00020.66
8.3.10.0040.00424.11
8.3.00.0030.00521.29
8.2.180.0170.00317.00
8.2.170.0140.00422.96
8.2.160.0030.01022.80
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0030.00522.63
8.2.110.0060.00322.94
8.2.100.0040.00818.28
8.2.90.0060.00319.58
8.2.80.0040.00418.30
8.2.70.0080.00018.13
8.2.60.0000.00918.30
8.2.50.0080.00018.07
8.2.40.0030.00519.96
8.2.30.0030.00618.63
8.2.20.0090.00018.11
8.2.10.0040.00418.18
8.2.00.0080.00318.34
8.1.280.0110.00725.92
8.1.270.0040.00424.20
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00324.21
8.1.230.0040.00719.60
8.1.220.0060.00317.93
8.1.210.0040.00418.77
8.1.200.0090.00517.75
8.1.190.0000.00818.03
8.1.180.0000.00818.10
8.1.170.0060.00319.16
8.1.160.0000.00822.59
8.1.150.0050.00218.93
8.1.140.0040.00417.79
8.1.130.0030.00318.34
8.1.120.0000.00717.76
8.1.110.0000.00717.90
8.1.100.0080.00017.85
8.1.90.0040.00417.92
8.1.80.0000.00717.70
8.1.70.0030.00317.69
8.1.60.0000.00918.04
8.1.50.0040.00417.85
8.1.40.0040.00417.91
8.1.30.0050.00317.93
8.1.20.0000.00817.93
8.1.10.0080.00018.05
8.1.00.0000.00917.83
8.0.300.0040.00418.77
8.0.290.0040.00417.55
8.0.280.0040.00418.86
8.0.270.0050.00217.60
8.0.260.0000.00917.37
8.0.250.0070.00017.43
8.0.240.0000.00717.32
8.0.230.0000.00717.55
8.0.220.0000.00717.44
8.0.210.0000.00717.38
8.0.200.0070.00017.44
8.0.190.0060.00317.48
8.0.180.0060.00317.41
8.0.170.0050.00317.32
8.0.160.0040.00417.52
8.0.150.0040.00417.19
8.0.140.0000.00717.37
8.0.130.0030.00313.89
8.0.120.0030.00517.34
8.0.110.0000.00817.20
8.0.100.0020.00517.32
8.0.90.0040.00417.40
8.0.80.0040.01217.30
8.0.70.0000.00717.30
8.0.60.0070.00017.25
8.0.50.0040.00417.27
8.0.30.0090.01017.43
8.0.20.0110.00817.59
8.0.10.0040.00417.29
8.0.00.0090.01117.09
7.4.330.0000.00515.51
7.4.320.0030.00317.03
7.4.300.0070.00017.01
7.4.290.0000.00717.02
7.4.280.0000.00717.06
7.4.270.0070.00016.84
7.4.260.0050.00516.87
7.4.250.0070.00016.71
7.4.240.0030.00416.93
7.4.230.0040.00416.82
7.4.220.0030.01516.90
7.4.210.0060.01116.96
7.4.200.0070.00016.96
7.4.190.0000.00817.04
7.4.160.0120.00417.15
7.4.150.0110.00717.40
7.4.140.0110.01017.86
7.4.130.0130.00617.03
7.4.120.0120.00517.06
7.4.110.0100.00716.91
7.4.100.0110.01416.99
7.4.90.0160.00616.70
7.4.80.0090.00917.10
7.4.70.0070.01016.98
7.4.60.0060.01517.18
7.4.50.0040.00416.76
7.4.40.0060.00622.77
7.4.30.0090.00616.99
7.4.00.0160.00015.37
7.3.330.0000.00613.58
7.3.320.0050.00013.85
7.3.310.0040.00416.81
7.3.300.0070.00016.81
7.3.290.0070.01016.84
7.3.280.0080.01116.79
7.3.270.0100.00717.40
7.3.260.0180.00716.94
7.3.250.0110.00716.80
7.3.240.0070.01016.81
7.3.230.0130.00316.84
7.3.210.0140.00816.89
7.3.200.0150.00319.39
7.3.190.0090.00817.09
7.3.180.0030.01317.12
7.3.170.0090.00616.93
7.3.160.0130.00416.91
7.3.120.0030.00915.01
7.3.10.0080.00616.62
7.3.00.0180.00716.64
7.2.330.0060.01016.97
7.2.320.0030.01616.91
7.2.310.0130.00317.21
7.2.300.0100.00717.22
7.2.290.0120.00916.87
7.2.130.0120.00517.00
7.2.120.0070.00716.87
7.2.110.0060.01016.89
7.2.100.0150.00516.93
7.2.90.0190.00717.02
7.2.80.0130.00217.01
7.2.70.0020.01116.91
7.2.60.0040.00717.02
7.2.50.0090.00717.03
7.2.40.0050.01117.08
7.2.30.0070.00917.12
7.2.20.0070.00517.00
7.2.10.0050.00916.95
7.2.00.0020.00917.97
7.1.250.0140.00615.90
7.1.200.0060.00915.96
7.1.100.0040.00818.35
7.1.70.0000.00817.13
7.1.60.0040.01119.22
7.1.50.0170.01334.86
7.1.00.0030.07722.53
7.0.200.0030.00616.68
7.0.140.0030.07022.13
7.0.100.0100.04720.14
7.0.90.0070.06320.04
7.0.80.0070.05720.17
7.0.70.0070.09020.14
7.0.60.0130.07320.07
7.0.50.0100.06320.50
7.0.40.0100.06720.31
7.0.30.0030.08320.23
7.0.20.0070.08320.22
7.0.10.0100.07720.30
7.0.00.0170.07720.21
5.6.280.0030.07321.26
5.6.250.0070.06320.89
5.6.240.0070.09020.81
5.6.230.0100.08020.74
5.6.220.0100.07320.83
5.6.210.0100.07320.86
5.6.200.0070.08721.24
5.6.190.0130.07721.21
5.6.180.0030.05021.14
5.6.170.0030.08721.28
5.6.160.0130.07721.20
5.6.150.0070.08721.29
5.6.140.0100.07321.30
5.6.130.0100.03721.21
5.6.120.0030.04321.11
5.6.110.0000.05321.21
5.6.100.0070.07021.31
5.6.90.0130.07721.29
5.6.80.0100.07320.66
5.6.70.0070.07320.67
5.6.60.0070.07320.62
5.6.50.0070.06720.61
5.6.40.0030.08020.71
5.6.30.0030.06720.53
5.6.20.0070.05020.66
5.6.10.0030.08020.68
5.6.00.0030.07720.50
5.5.380.0130.04320.68
5.5.370.0100.07320.65
5.5.360.0170.06720.66
5.5.350.0070.08720.68
5.5.340.0100.08321.00
5.5.330.0100.04321.06
5.5.320.0070.08321.08
5.5.310.0000.09021.02
5.5.300.0130.06721.02
5.5.290.0070.04021.14
5.5.280.0070.08020.93
5.5.270.0070.06021.09
5.5.260.0070.04721.11
5.5.250.0100.07020.76
5.5.240.0070.07720.29
5.5.230.0130.07020.52
5.5.220.0030.07720.34
5.5.210.0070.07720.42
5.5.200.0100.07320.39
5.5.190.0130.06720.39
5.5.180.0100.07320.49
5.5.160.0070.04020.36
5.5.150.0070.07720.35
5.5.140.0030.04720.46
5.5.130.0030.08020.25
5.5.120.0000.06720.46
5.5.110.0100.05320.46
5.5.100.0030.04720.36
5.5.90.0170.07020.38
5.5.80.0100.04320.30
5.5.70.0000.09020.20
5.5.60.0170.07020.18
5.5.50.0070.07720.29
5.5.40.0130.05020.32
5.5.30.0070.04020.27
5.5.20.0030.08020.33
5.5.10.0130.06320.25
5.5.00.0100.04320.32
5.4.450.0130.03319.42
5.4.440.0170.04019.50
5.4.430.0170.06719.68
5.4.420.0000.05019.50
5.4.410.0100.04019.38
5.4.400.0030.06719.31
5.4.390.0070.07319.20
5.4.380.0000.08019.11
5.4.370.0170.06719.33
5.4.360.0070.07019.32
5.4.350.0100.03019.30
5.4.340.0070.05719.36
5.4.320.0100.07019.36
5.4.310.0000.04319.44
5.4.300.0000.05019.20
5.4.290.0100.07019.34
5.4.280.0030.06319.30
5.4.270.0070.06719.09
5.4.260.0130.03719.33
5.4.250.0030.06719.30
5.4.240.0070.07719.33
5.4.230.0000.08319.29
5.4.220.0100.08019.17
5.4.210.0000.04319.11
5.4.200.0030.06719.08
5.4.190.0030.08319.17
5.4.180.0100.06719.12
5.4.170.0030.04019.11
5.4.160.0070.07019.29
5.4.150.0070.07019.16
5.4.140.0100.06716.75
5.4.130.0030.06316.72
5.4.120.0030.07716.68
5.4.110.0100.07016.54
5.4.100.0130.07016.71
5.4.90.0100.06716.57
5.4.80.0100.06716.60
5.4.70.0070.05716.63
5.4.60.0070.06716.82
5.4.50.0000.07716.66
5.4.40.0070.06716.63
5.4.30.0130.06716.66
5.4.20.0070.07316.74
5.4.10.0030.07016.83
5.4.00.0100.07315.97
5.3.290.0030.04314.90
5.3.280.0100.07014.95
5.3.270.0030.05714.81
5.3.260.0030.08314.83
5.3.250.0100.07014.83
5.3.240.0130.06314.83
5.3.230.0130.06714.95
5.3.220.0130.05014.80
5.3.210.0030.07714.87
5.3.200.0130.06314.88
5.3.190.0100.04014.83
5.3.180.0130.07014.79
5.3.170.0100.07014.80
5.3.160.0030.04014.91
5.3.150.0030.06714.83
5.3.140.0030.07714.87
5.3.130.0070.06314.89
5.3.120.0000.08014.78
5.3.110.0100.07014.71
5.3.100.0070.03714.30
5.3.90.0030.07714.25
5.3.80.0070.06014.25
5.3.70.0030.07314.14
5.3.60.0130.05714.31
5.3.50.0030.06014.21
5.3.40.0070.07714.18
5.3.30.0100.07314.14
5.3.20.0130.05714.05
5.3.10.0030.04313.87
5.3.00.0000.05713.83
5.2.170.0070.05311.45
5.2.160.0030.06311.36
5.2.150.0100.03011.38
5.2.140.0030.06311.28
5.2.130.0100.04711.41
5.2.120.0000.06711.32
5.2.110.0070.05311.46
5.2.100.0000.03011.32
5.2.90.0030.06011.42
5.2.80.0000.06311.25
5.2.70.0000.04711.41
5.2.60.0070.05311.36
5.2.50.0000.04011.37
5.2.40.0070.06311.11
5.2.30.0070.05311.09
5.2.20.0000.06311.18
5.2.10.0130.05011.07
5.2.00.0000.04710.87
5.1.60.0030.04310.18
5.1.50.0070.04710.23
5.1.40.0070.03310.31
5.1.30.0100.05310.54
5.1.20.0000.06010.43
5.1.10.0030.05310.08
5.1.00.0070.05010.10
5.0.50.0130.0378.58
5.0.40.0030.0438.53
5.0.30.0070.0508.36
5.0.20.0030.0438.33
5.0.10.0030.0378.29
5.0.00.0030.0638.29
4.4.90.0000.0378.29
4.4.80.0000.0408.29
4.4.70.0000.0408.29
4.4.60.0000.0378.29
4.4.50.0030.0338.29
4.4.40.0000.0478.29
4.4.30.0030.0308.29
4.4.20.0000.0238.29
4.4.10.0030.0178.29
4.4.00.0070.0508.29
4.3.110.0070.0308.29
4.3.100.0000.0208.29
4.3.90.0070.0178.29
4.3.80.0030.0278.29
4.3.70.0030.0338.29
4.3.60.0000.0378.29
4.3.50.0030.0308.29
4.3.40.0000.0538.29
4.3.30.0000.0378.29
4.3.20.0000.0338.29
4.3.10.0070.0278.29
4.3.00.0000.0378.29

preferences:
42.92 ms | 401 KiB | 5 Q