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 . ')[' . $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.00317.13
8.3.50.0280.00316.80
8.3.40.0120.00619.29
8.3.30.0060.01019.21
8.3.20.0050.00319.20
8.3.10.0000.00821.08
8.3.00.0050.00519.75
8.2.180.0090.00917.00
8.2.170.0040.01122.96
8.2.160.0070.01021.88
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0050.00321.33
8.2.110.0090.00021.45
8.2.100.0080.00418.47
8.2.90.0040.00419.75
8.2.80.0000.00818.00
8.2.70.0080.00018.00
8.2.60.0050.00318.43
8.2.50.0000.00918.25
8.2.40.0040.00418.84
8.2.30.0070.00018.55
8.2.20.0040.00418.08
8.2.10.0000.00918.14
8.2.00.0060.00618.10
8.1.270.0080.00024.66
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0120.00922.98
8.1.230.0040.00817.89
8.1.220.0030.00618.26
8.1.210.0000.00818.77
8.1.200.0040.00417.86
8.1.190.0000.00818.01
8.1.180.0040.00418.10
8.1.170.0040.00419.11
8.1.160.0060.00319.28
8.1.150.0040.00419.12
8.1.140.0000.00817.85
8.1.130.0000.00718.16
8.1.120.0000.00717.89
8.1.110.0040.00417.84
8.1.100.0000.00817.94
8.1.90.0040.00417.82
8.1.80.0030.00517.72
8.1.70.0000.00817.95
8.1.60.0090.00018.09
8.1.50.0060.00317.80
8.1.40.0070.00418.05
8.1.30.0000.00818.12
8.1.20.0040.00417.97
8.1.10.0000.00917.98
8.1.00.0000.00917.99
8.0.300.0050.00318.77
8.0.290.0000.00816.88
8.0.280.0000.00818.94
8.0.270.0000.00717.61
8.0.260.0000.00717.27
8.0.250.0080.00017.40
8.0.240.0060.00317.49
8.0.230.0030.00617.43
8.0.220.0070.00317.34
8.0.210.0040.00417.35
8.0.200.0000.00717.43
8.0.190.0030.00617.36
8.0.180.0030.00617.39
8.0.170.0030.00617.26
8.0.160.0040.00417.34
8.0.150.0030.00617.23
8.0.140.0040.00917.34
8.0.130.0000.00613.74
8.0.120.0040.00417.17
8.0.110.0040.00417.27
8.0.100.0070.00017.29
8.0.90.0040.00417.23
8.0.80.0090.00617.32
8.0.70.0000.00817.27
8.0.60.0080.00017.36
8.0.50.0040.00417.29
8.0.30.0060.01317.52
8.0.20.0120.00717.42
8.0.10.0000.00717.39
8.0.00.0070.01017.14
7.4.330.0000.00613.45
7.4.320.0030.00317.00
7.4.300.0050.00316.96
7.4.290.0030.00317.11
7.4.280.0060.00316.88
7.4.270.0040.00417.03
7.4.260.0050.00013.73
7.4.250.0030.00616.95
7.4.240.0030.00516.91
7.4.230.0040.00416.84
7.4.220.0130.01317.00
7.4.210.0050.01117.03
7.4.200.0000.00716.94
7.4.190.0000.00716.90
7.4.160.0130.00717.07
7.4.150.0120.00617.06
7.4.140.0130.00816.98
7.4.130.0110.00717.01
7.4.120.0080.00816.97
7.4.110.0120.00616.98
7.4.100.0180.00016.84
7.4.90.0060.01617.09
7.4.80.0040.01319.39
7.4.70.0150.00916.81
7.4.60.0100.00716.89
7.4.50.0090.00016.95
7.4.40.0060.00916.79
7.4.30.0110.00616.89
7.4.00.0090.00615.09
7.3.330.0000.00713.55
7.3.320.0000.00613.78
7.3.310.0040.00416.60
7.3.300.0030.00516.70
7.3.290.0070.01116.80
7.3.280.0090.01016.79
7.3.270.0080.00816.92
7.3.260.0090.00916.85
7.3.250.0120.00516.83
7.3.240.0100.00717.14
7.3.230.0090.00916.85
7.3.210.0140.00417.19
7.3.200.0090.00916.86
7.3.190.0100.01316.70
7.3.180.0090.00916.98
7.3.170.0110.01117.04
7.3.160.0110.00517.03
7.3.120.0060.01015.05
7.3.110.0070.00714.82
7.3.100.0060.00914.85
7.3.90.0100.00314.98
7.3.80.0030.01015.11
7.3.70.0060.00615.07
7.3.60.0030.00615.10
7.3.50.0030.01315.08
7.3.40.0000.00914.98
7.3.30.0060.00615.05
7.3.20.0060.00916.91
7.3.10.0090.00316.73
7.3.00.0000.01316.89
7.2.330.0090.00917.07
7.2.320.0120.00616.81
7.2.310.0090.01216.90
7.2.300.0150.00317.14
7.2.290.0100.00717.29
7.2.240.0000.01015.60
7.2.230.0140.00315.25
7.2.220.0060.00915.42
7.2.210.0000.01315.07
7.2.200.0080.00815.11
7.2.190.0060.00915.38
7.2.180.0110.00715.18
7.2.170.0070.00715.19
7.2.160.0100.00315.20
7.2.150.0120.00317.05
7.2.140.0000.01116.96
7.2.130.0080.00417.04
7.2.120.0100.00317.02
7.2.110.0070.00717.06
7.2.100.0110.00417.03
7.2.90.0100.00317.37
7.2.80.0040.00717.15
7.2.70.0140.00317.28
7.2.60.0080.00817.22
7.2.50.0090.00317.05
7.2.40.0030.01317.11
7.2.30.0040.00817.06
7.2.20.0060.00917.14
7.2.10.0000.01617.25
7.2.00.0060.00617.01
7.1.330.0000.01715.77
7.1.320.0070.00716.07
7.1.310.0060.00616.02
7.1.300.0070.00715.98
7.1.290.0060.00816.00
7.1.280.0000.01315.89
7.1.270.0040.00716.07
7.1.260.0040.00815.92
7.1.250.0070.00715.84
7.1.70.0000.00717.09
7.1.60.0100.01419.40
7.1.50.0100.00716.91
7.1.00.0070.03022.66
7.0.200.0120.00616.97
7.0.140.0030.07722.24
7.0.120.0030.06722.34
7.0.60.0230.07720.26
7.0.50.0000.08718.15
7.0.40.0070.06020.33
7.0.30.0030.08320.27
7.0.20.0070.06320.52
7.0.10.0100.04320.30
7.0.00.0000.04720.55
5.6.210.0070.03720.64
5.6.200.0100.08318.40
5.6.190.0070.05720.86
5.6.180.0100.04020.68
5.6.170.0170.08320.86
5.6.160.0030.06020.55
5.6.150.0130.04320.72
5.6.140.0070.08020.52
5.6.130.0170.07020.48
5.6.120.0070.04320.47
5.6.110.0100.08020.52
5.6.100.0130.04020.32
5.6.90.0070.04320.45
5.6.80.0000.05319.74
5.6.70.0070.03720.00
5.6.60.0030.04019.87
5.6.50.0030.04019.74
5.6.40.0000.04319.98
5.6.30.0030.05019.99
5.6.20.0070.04719.81
5.6.10.0100.03319.88
5.6.00.0000.04319.84
5.5.350.0070.03720.56
5.5.340.0100.07718.29
5.5.330.0070.07320.74
5.5.320.0000.05720.46
5.5.310.0100.08720.65
5.5.300.0030.09020.54
5.5.290.0100.06020.44
5.5.280.0070.05720.29
5.5.270.0100.05320.29
5.5.260.0170.05320.12
5.5.250.0030.04320.00
5.5.240.0030.04319.69
5.5.230.0000.04319.65
5.5.220.0100.03719.67
5.5.210.0070.03719.70
5.5.200.0030.04019.88
5.5.190.0000.04319.83
5.5.180.0000.04319.78
5.5.160.0130.03019.77
5.5.150.0000.04319.48
5.5.140.0030.04019.54
5.5.130.0070.03719.48
5.5.120.0070.03719.86
5.5.110.0030.04019.46
5.5.100.0030.05719.77
5.5.90.0070.03719.77
5.5.80.0030.04719.77
5.5.70.0000.04319.49
5.5.60.0030.04019.70
5.5.50.0030.03719.75
5.5.40.0000.04019.78
5.5.30.0030.04019.75
5.5.20.0100.03019.48
5.5.10.0030.04019.54
5.5.00.0130.06319.48
5.4.450.0100.07019.86
5.4.440.0000.04319.70
5.4.430.0070.07719.35
5.4.420.0070.05319.40
5.4.410.0070.07719.73
5.4.400.0070.03719.24
5.4.390.0000.04319.29
5.4.380.0000.04019.21
5.4.370.0000.04019.46
5.4.360.0000.04019.37
5.4.350.0070.03319.46
5.4.340.0070.03319.25
5.4.320.0000.04019.30
5.4.310.0030.03719.01
5.4.300.0030.03719.23
5.4.290.0030.03719.02
5.4.280.0030.03719.28
5.4.270.0030.03719.00
5.4.260.0030.04019.25
5.4.250.0030.04019.36
5.4.240.0070.03319.01
5.4.230.0000.04019.00
5.4.220.0000.04019.36
5.4.210.0000.04019.02
5.4.200.0070.03319.16
5.4.190.0100.03719.20
5.4.180.0000.04019.47
5.4.170.0030.03718.99
5.4.160.0100.07019.19
5.4.150.0100.04319.06
5.4.140.0070.03316.75
5.4.130.0100.03716.75
5.4.120.0100.06716.67
5.4.110.0070.03716.68
5.4.100.0030.05716.57
5.4.90.0070.07316.70
5.4.80.0070.03316.79
5.4.70.0070.03316.58
5.4.60.0070.03316.60
5.4.50.0130.06716.66
5.4.40.0030.06016.59
5.4.30.0030.04016.64
5.4.20.0000.04016.73
5.4.10.0030.04016.62
5.4.00.0100.06016.20
5.3.290.0100.03014.88
5.3.280.0030.04014.80
5.3.270.0000.04014.86
5.3.260.0000.04014.92
5.3.250.0070.03314.84
5.3.240.0030.03714.86
5.3.230.0070.06014.93
5.3.220.0070.06714.82
5.3.210.0000.05014.84
5.3.200.0030.04314.91
5.3.190.0070.07714.81
5.3.180.0030.05014.78
5.3.170.0070.07314.79
5.3.160.0070.04714.84
5.3.150.0100.07314.80
5.3.140.0070.04314.90
5.3.130.0030.03714.81
5.3.120.0070.03714.80
5.3.110.0130.07314.81
5.3.100.0000.08014.37
5.3.90.0130.06014.26
5.3.80.0030.08014.35
5.3.70.0070.07714.14
5.3.60.0070.06314.32
5.3.50.0030.04314.21
5.3.40.0070.03314.26
5.3.30.0070.03714.17
5.3.20.0070.07313.86
5.3.10.0100.03313.95
5.3.00.0030.03713.80
5.2.170.0030.03011.31
5.2.160.0030.03311.34
5.2.150.0000.06711.45
5.2.140.0030.07311.44
5.2.130.0030.05311.34
5.2.120.0030.03711.34
5.2.110.0100.05711.43
5.2.100.0030.03011.30
5.2.90.0000.07011.34
5.2.80.0070.03311.36
5.2.70.0030.03011.43
5.2.60.0000.05711.29
5.2.50.0100.06311.34
5.2.40.0030.06711.25
5.2.30.0170.04711.12
5.2.20.0030.06011.29
5.2.10.0100.04011.09
5.2.00.0030.03310.91
5.1.60.0030.03710.25
5.1.50.0130.03310.25
5.1.40.0030.03010.30
5.1.30.0030.05710.56
5.1.20.0030.04710.56
5.1.10.0170.04710.11
5.1.00.0030.05710.16
5.0.50.0030.0278.48
5.0.40.0000.0238.44
5.0.30.0000.0678.34
5.0.20.0070.0278.34
5.0.10.0030.0238.34
5.0.00.0000.0678.34
4.4.90.0000.0378.34
4.4.80.0000.0208.34
4.4.70.0070.0338.34
4.4.60.0000.0408.34
4.4.50.0000.0338.34
4.4.40.0070.0238.34
4.4.30.0000.0238.34
4.4.20.0070.0238.34
4.4.10.0030.0338.34
4.4.00.0030.0278.34
4.3.110.0030.0338.34
4.3.100.0070.0308.34
4.3.90.0000.0208.34
4.3.80.0000.0408.34
4.3.70.0030.0338.34
4.3.60.0030.0178.34
4.3.50.0000.0338.34
4.3.40.0000.0408.34
4.3.30.0070.0338.34
4.3.20.0000.0278.34
4.3.10.0000.0238.34
4.3.00.0070.0308.34

preferences:
59.85 ms | 400 KiB | 5 Q