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 (preg_match('/(\w+)\[(\d+)\]/', $offset, $nodes)) { var_dump($this->xml->val[0]->asXML()); return new self($this->xml->$nodes[1][$nodes[2]]->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']; $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.0180.00318.93
8.3.50.0140.00522.32
8.3.40.0150.00419.41
8.3.30.0070.01119.52
8.3.20.0050.00320.50
8.3.10.0000.00822.34
8.3.00.0030.00622.59
8.2.180.0070.01017.13
8.2.170.0120.00322.96
8.2.160.0090.00621.22
8.2.150.0050.00324.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0040.00419.92
8.2.110.0040.00422.46
8.2.100.0080.00418.28
8.2.90.0000.00819.50
8.2.80.0040.00418.18
8.2.70.0060.00718.13
8.2.60.0000.00918.29
8.2.50.0090.00018.13
8.2.40.0050.00318.47
8.2.30.0030.00518.49
8.2.20.0050.00318.32
8.2.10.0080.00019.93
8.2.00.0060.00318.07
8.1.280.0120.00625.92
8.1.270.0040.00424.23
8.1.260.0000.00926.35
8.1.250.0090.00028.09
8.1.240.0060.00324.16
8.1.230.0060.00619.42
8.1.220.0040.00417.91
8.1.210.0060.00318.77
8.1.200.0000.01017.98
8.1.190.0060.00317.91
8.1.180.0100.00018.10
8.1.170.0050.00319.16
8.1.160.0000.00722.32
8.1.150.0040.00419.12
8.1.140.0000.00817.84
8.1.130.0000.00718.12
8.1.120.0040.00417.80
8.1.110.0000.00817.79
8.1.100.0030.00517.76
8.1.90.0030.00617.80
8.1.80.0050.00217.89
8.1.70.0030.00317.91
8.1.60.0030.00617.91
8.1.50.0030.00518.00
8.1.40.0030.00517.91
8.1.30.0060.00318.09
8.1.20.0080.00018.10
8.1.10.0000.00917.96
8.1.00.0040.00417.93
8.0.300.0080.00018.77
8.0.290.0000.00717.54
8.0.280.0000.00718.62
8.0.270.0070.00017.40
8.0.260.0030.00317.27
8.0.250.0070.00017.43
8.0.240.0000.00717.48
8.0.230.0030.00517.44
8.0.220.0070.00017.28
8.0.210.0040.00417.44
8.0.200.0040.00417.34
8.0.190.0030.00517.51
8.0.180.0090.00317.40
8.0.170.0050.00317.45
8.0.160.0070.00017.36
8.0.150.0040.00417.23
8.0.140.0000.00717.24
8.0.130.0000.00613.84
8.0.120.0000.00917.25
8.0.110.0040.00417.29
8.0.100.0050.00317.43
8.0.90.0060.00317.46
8.0.80.0030.01417.43
8.0.70.0040.00417.34
8.0.60.0000.00717.43
8.0.50.0030.00517.23
8.0.30.0180.00817.50
8.0.20.0170.00517.58
8.0.10.0000.00717.32
8.0.00.0050.01317.22
7.4.330.0000.00615.48
7.4.320.0000.00617.04
7.4.300.0030.00517.04
7.4.290.0000.00817.14
7.4.280.0030.00316.90
7.4.270.0050.00317.12
7.4.260.0000.00717.11
7.4.250.0050.00316.96
7.4.240.0020.00617.05
7.4.230.0040.00316.97
7.4.220.0040.01517.03
7.4.210.0060.01117.02
7.4.200.0080.00017.04
7.4.190.0040.00417.27
7.4.160.0170.00017.19
7.4.150.0210.00617.40
7.4.140.0120.00717.86
7.4.130.0080.00917.08
7.4.120.0070.01116.99
7.4.110.0130.01017.06
7.4.100.0150.00917.10
7.4.90.0070.01117.17
7.4.80.0100.01319.39
7.4.70.0030.01317.00
7.4.60.0060.01217.01
7.4.50.0050.00017.14
7.4.40.0090.00622.77
7.4.30.0120.00917.00
7.4.00.0040.01215.24
7.3.330.0000.00513.64
7.3.320.0050.00013.86
7.3.310.0070.00016.90
7.3.300.0070.00016.79
7.3.290.0130.00316.88
7.3.280.0080.01016.87
7.3.270.0180.00317.40
7.3.260.0120.00616.87
7.3.250.0080.01016.91
7.3.240.0000.01717.08
7.3.230.0100.00717.13
7.3.210.0090.00917.01
7.3.200.0170.00519.39
7.3.190.0140.00317.17
7.3.180.0110.00716.86
7.3.170.0090.00816.88
7.3.160.0060.01016.80
7.3.120.0110.00715.12
7.3.110.0030.01415.40
7.3.100.0060.00915.10
7.3.90.0020.01115.25
7.3.80.0050.00815.22
7.3.70.0020.01415.22
7.3.60.0050.01015.17
7.3.50.0010.01115.25
7.3.40.0090.00315.15
7.3.30.0120.00315.03
7.3.20.0070.00917.02
7.3.10.0060.01016.99
7.3.00.0030.01117.08
7.2.330.0110.00717.21
7.2.320.0140.00617.14
7.2.310.0120.01516.91
7.2.300.0030.01517.10
7.2.290.0090.00917.11
7.2.250.0040.01515.45
7.2.240.0090.01115.55
7.2.230.0050.01115.33
7.2.220.0070.00715.19
7.2.210.0080.00515.44
7.2.200.0090.00715.45
7.2.190.0030.01115.46
7.2.180.0030.01615.50
7.2.170.0070.00715.50
7.2.60.0070.00717.27
7.1.330.0100.00516.29
7.1.320.0000.01516.13
7.1.310.0030.01016.28
7.1.300.0090.00815.89
7.1.290.0110.00516.01
7.1.280.0120.00416.14
7.1.270.0040.00916.01
7.1.260.0050.00515.94
7.1.200.0140.00716.02
7.1.70.0040.00817.21
7.1.60.0130.01319.82
7.1.50.0060.01517.31
7.1.00.0130.06722.57
7.0.200.0100.00317.02
7.0.140.0030.07322.04
7.0.100.0570.07320.08
7.0.90.0230.05020.26
7.0.80.0530.06320.12
7.0.70.0400.04719.98
7.0.60.0430.06719.98
7.0.50.0470.07320.33
7.0.40.0130.07320.18
7.0.30.0100.04720.17
7.0.20.0100.05720.24
7.0.10.0100.04020.21
7.0.00.0100.08320.23
5.6.280.0070.07021.22
5.6.250.0030.08720.79
5.6.240.0100.05720.61
5.6.230.0130.06720.73
5.6.220.0070.08720.72
5.6.210.0100.08320.53
5.6.200.0170.08021.19
5.6.190.0070.08321.15
5.6.180.0170.05321.01
5.6.170.0000.08321.09
5.6.160.0100.05321.21
5.6.150.0100.07321.17
5.6.140.0030.08721.09
5.6.130.0130.08021.17
5.6.120.0070.07721.15
5.6.110.0130.07721.30
5.6.100.0170.06021.18
5.6.90.0170.07321.14
5.6.80.0100.06720.55
5.6.70.0100.07720.55
5.6.60.0070.08020.51
5.6.50.0030.04320.64
5.6.40.0070.08020.54
5.6.30.0130.06720.63
5.6.20.0070.06320.36
5.6.10.0070.06720.47
5.6.00.0000.08320.52
5.5.380.0070.08020.49
5.5.370.0170.06020.45
5.5.360.0130.07320.44
5.5.350.0070.08720.48
5.5.340.0070.08320.98
5.5.330.0030.06320.84
5.5.320.0070.08320.88
5.5.310.0130.06321.00
5.5.300.0070.07320.91
5.5.290.0000.08720.88
5.5.280.0070.08021.00
5.5.270.0230.06721.05
5.5.260.0030.08721.06
5.5.250.0070.08320.79
5.5.240.0030.05020.46
5.5.230.0130.07320.26
5.5.220.0130.07020.29
5.5.210.0030.08020.22
5.5.200.0130.07020.36
5.5.190.0130.04320.25
5.5.180.0000.08720.32
5.5.160.0000.07320.23
5.5.150.0100.06720.35
5.5.140.0100.07320.25
5.5.130.0030.05320.31
5.5.120.0030.03720.35
5.5.110.0070.03720.22
5.5.100.0070.03720.27
5.5.90.0030.03720.14
5.5.80.0070.03320.30
5.5.70.0070.07720.11
5.5.60.0070.03320.23
5.5.50.0070.03320.13
5.5.40.0030.04020.22
5.5.30.0030.04020.11
5.5.20.0100.05720.12
5.5.10.0000.04320.19
5.5.00.0000.04020.05
5.4.450.0030.08719.71
5.4.440.0130.07019.60
5.4.430.0100.07719.26
5.4.420.0000.05319.57
5.4.410.0100.07019.49
5.4.400.0100.07319.12
5.4.390.0070.07719.25
5.4.380.0100.07019.29
5.4.370.0070.05019.11
5.4.360.0130.07019.38
5.4.350.0030.07319.25
5.4.340.0070.06719.24
5.4.320.0170.06019.30
5.4.310.0030.07319.34
5.4.300.0070.07319.26
5.4.290.0000.08018.93
5.4.280.0030.04019.38
5.4.270.0070.03719.32
5.4.260.0030.03718.93
5.4.250.0000.05019.23
5.4.240.0000.04019.26
5.4.230.0000.04019.37
5.4.220.0070.03319.23
5.4.210.0030.03719.23
5.4.200.0030.03719.26
5.4.190.0030.03718.92
5.4.180.0030.03719.12
5.4.170.0030.03719.13
5.4.160.0100.03019.23
5.4.150.0030.03719.26
5.4.140.0030.07016.57
5.4.130.0030.03316.65
5.4.120.0000.04016.54
5.4.110.0070.03316.61
5.4.100.0070.06716.50
5.4.90.0070.05316.47
5.4.80.0000.03716.59
5.4.70.0100.04316.63
5.4.60.0030.04016.57
5.4.50.0030.04016.51
5.4.40.0030.03316.68
5.4.30.0100.05716.58
5.4.20.0000.04716.59
5.4.10.0070.07016.54
5.4.00.0030.03716.10
5.3.290.0070.03714.82
5.3.280.0130.02714.76
5.3.270.0000.04014.77
5.3.260.0030.03314.82
5.3.250.0070.06714.75
5.3.240.0130.02714.68
5.3.230.0000.04014.80
5.3.220.0070.04014.65
5.3.210.0070.03314.80
5.3.200.0000.05314.77
5.3.190.0100.06014.71
5.3.180.0070.05314.73
5.3.170.0000.04014.82
5.3.160.0030.06314.76
5.3.150.0070.03314.76
5.3.140.0000.04014.64
5.3.130.0030.04014.64
5.3.120.0030.03714.71
5.3.110.0000.04314.77
5.3.100.0030.06314.13
5.3.90.0030.03714.11
5.3.80.0070.03314.21
5.3.70.0000.04014.26
5.3.60.0000.03714.24
5.3.50.0030.03314.12
5.3.40.0000.04014.11
5.3.30.0070.03714.20
5.3.20.0070.03713.71
5.3.10.0000.03313.94
5.3.00.0000.04013.65
5.2.170.0000.03011.31
5.2.160.0030.02711.38
5.2.150.0030.03011.38
5.2.140.0000.03011.41
5.2.130.0030.03011.27
5.2.120.0070.03711.37
5.2.110.0000.03711.27
5.2.100.0030.02711.34
5.2.90.0030.03311.10
5.2.80.0070.04711.11
5.2.70.0030.06011.37
5.2.60.0000.05311.20
5.2.50.0000.04711.25
5.2.40.0070.05011.16
5.2.30.0070.06311.18
5.2.20.0000.06310.98
5.2.10.0070.05011.00
5.2.00.0100.03710.99
5.1.60.0100.04710.13
5.1.50.0130.04010.11
5.1.40.0070.05010.16
5.1.30.0070.05310.34
5.1.20.0070.05710.61
5.1.10.0000.05710.16
5.1.00.0030.0509.94
5.0.50.0070.0438.64
5.0.40.0070.0408.32
5.0.30.0070.0608.25
5.0.20.0000.0478.33
5.0.10.0100.0308.27
5.0.00.0030.0408.09
4.4.90.0000.0337.98
4.4.80.0130.0177.98
4.4.70.0030.0307.98
4.4.60.0070.0237.98
4.4.50.0030.0337.98
4.4.40.0030.0477.98
4.4.30.0030.0307.98
4.4.20.0000.0377.98
4.4.10.0030.0337.98
4.4.00.0000.0577.98
4.3.110.0030.0377.98
4.3.100.0000.0377.98
4.3.90.0100.0137.98
4.3.80.0000.0577.98
4.3.70.0030.0177.98
4.3.60.0100.0277.98
4.3.50.0030.0507.98
4.3.40.0070.0477.98
4.3.30.0070.0307.98
4.3.20.0000.0377.98
4.3.10.0070.0307.98
4.3.00.0000.0277.98

preferences:
42.87 ms | 401 KiB | 5 Q