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->$nodes[1][$nodes[2]]->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.0070.01116.88
8.3.50.0120.00922.21
8.3.40.0040.01119.33
8.3.30.0070.00719.55
8.3.20.0050.00320.58
8.3.10.0080.00023.91
8.3.00.0030.00619.76
8.2.180.0150.00725.92
8.2.170.0040.01119.41
8.2.160.0160.00622.96
8.2.150.0080.00025.66
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0040.00422.46
8.2.110.0030.00619.52
8.2.100.0090.00318.22
8.2.90.0080.00019.47
8.2.80.0000.00918.25
8.2.70.0090.00018.13
8.2.60.0050.00318.30
8.2.50.0050.00518.13
8.2.40.0060.00320.89
8.2.30.0030.00618.45
8.2.20.0000.00818.35
8.2.10.0040.00420.19
8.2.00.0060.00318.17
8.1.280.0040.01125.92
8.1.270.0030.00624.66
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00621.54
8.1.230.0070.00418.07
8.1.220.0060.00318.29
8.1.210.0060.00318.77
8.1.200.0090.00017.86
8.1.190.0000.00817.85
8.1.180.0040.00418.10
8.1.170.0030.00618.84
8.1.160.0000.00822.32
8.1.150.0030.00519.18
8.1.140.0030.00517.90
8.1.130.0000.00718.15
8.1.120.0050.00217.81
8.1.110.0000.01017.78
8.1.100.0050.00517.86
8.1.90.0040.00417.78
8.1.80.0050.00217.84
8.1.70.0030.00417.81
8.1.60.0040.00417.89
8.1.50.0040.00417.96
8.1.40.0000.00817.81
8.1.30.0030.00618.06
8.1.20.0000.00818.09
8.1.10.0040.00418.01
8.1.00.0030.00517.86
8.0.300.0070.00318.77
8.0.290.0030.00717.25
8.0.280.0000.00718.75
8.0.270.0000.00817.44
8.0.260.0050.00317.47
8.0.250.0040.00417.52
8.0.240.0050.00317.48
8.0.230.0060.00317.38
8.0.220.0000.00717.41
8.0.210.0070.00017.32
8.0.200.0000.00717.42
8.0.190.0000.00917.48
8.0.180.0000.00717.37
8.0.170.0030.00517.43
8.0.160.0070.00017.41
8.0.150.0000.00717.27
8.0.140.0000.00817.39
8.0.130.0000.00613.89
8.0.120.0000.00817.39
8.0.110.0040.00417.41
8.0.100.0000.00817.34
8.0.90.0040.00417.16
8.0.80.0070.01317.38
8.0.70.0000.00717.44
8.0.60.0040.00417.20
8.0.50.0000.00817.43
8.0.30.0140.00517.45
8.0.20.0120.00717.84
8.0.10.0020.00517.36
8.0.00.0060.01117.32
7.4.330.0030.00315.42
7.4.320.0050.00217.05
7.4.300.0000.00717.12
7.4.290.0000.00717.01
7.4.280.0070.00017.03
7.4.270.0070.00017.11
7.4.260.0000.00717.11
7.4.250.0030.00517.11
7.4.240.0060.00216.97
7.4.230.0040.00417.13
7.4.220.0060.00917.01
7.4.210.0070.00817.08
7.4.200.0040.00417.10
7.4.190.0040.00417.27
7.4.160.0080.01616.93
7.4.150.0160.00317.40
7.4.140.0100.00717.86
7.4.130.0090.01017.00
7.4.120.0100.01116.98
7.4.110.0030.01616.90
7.4.100.0130.01017.04
7.4.90.0060.01716.95
7.4.80.0100.01619.39
7.4.70.0070.01017.07
7.4.60.0090.00917.13
7.4.50.0000.00917.07
7.4.40.0030.01322.77
7.4.30.0080.00817.03
7.4.00.0070.01015.45
7.3.330.0070.00013.61
7.3.320.0060.00013.82
7.3.310.0040.00416.84
7.3.300.0080.00016.90
7.3.290.0060.01216.91
7.3.280.0090.01116.80
7.3.270.0060.01217.40
7.3.260.0120.00616.76
7.3.250.0090.00816.96
7.3.240.0140.00516.90
7.3.230.0090.00916.93
7.3.210.0160.02516.98
7.3.200.0120.01119.39
7.3.190.0120.00917.06
7.3.180.0080.00817.14
7.3.170.0080.00816.87
7.3.160.0140.00616.92
7.3.120.0070.00715.16
7.3.10.0130.00616.37
7.3.00.0160.00416.46
7.2.330.0100.00717.22
7.2.320.0000.02217.10
7.2.310.0040.01317.11
7.2.300.0100.00717.28
7.2.290.0110.00716.97
7.2.130.0130.01116.44
7.2.120.0130.01017.02
7.2.110.0140.00716.97
7.2.100.0140.00816.76
7.2.90.0130.01317.06
7.2.80.0100.00917.26
7.2.70.0100.00616.92
7.2.60.0110.01116.97
7.2.50.0120.01917.16
7.2.40.0150.01016.93
7.2.30.0210.00316.93
7.2.20.0120.00616.69
7.2.10.0100.01617.05
7.2.00.0120.00317.02
7.1.250.0140.00715.80
7.1.200.0030.01016.07
7.1.70.0090.00617.14
7.1.60.0120.00919.46
7.1.50.0100.01017.19
7.1.00.0070.07022.57
7.0.200.0320.00615.03
7.0.140.0070.06022.10
7.0.100.0130.04020.14
7.0.90.0130.08020.10
7.0.80.0100.03720.04
7.0.70.0070.07720.06
7.0.60.0070.04720.08
7.0.50.0130.07720.49
7.0.40.0030.07320.09
7.0.30.0030.04720.21
7.0.20.0070.04320.24
7.0.10.0100.07320.24
7.0.00.0130.08720.18
5.6.280.0070.07021.20
5.6.250.0070.06021.00
5.6.240.0130.08320.67
5.6.230.0070.04020.90
5.6.220.0100.04720.80
5.6.210.0100.07720.96
5.6.200.0130.08321.20
5.6.190.0100.04021.14
5.6.180.0070.04721.15
5.6.170.0070.07021.14
5.6.160.0100.08021.03
5.6.150.0100.07721.03
5.6.140.0100.04321.16
5.6.130.0030.08321.30
5.6.120.0130.08021.10
5.6.110.0070.04021.22
5.6.100.0070.07021.17
5.6.90.0100.04321.13
5.6.80.0030.07020.50
5.6.70.0230.06320.55
5.6.60.0070.07720.57
5.6.50.0070.08720.39
5.6.40.0130.08020.50
5.6.30.0030.05320.57
5.6.20.0070.04720.49
5.6.10.0100.08020.43
5.6.00.0030.08720.55
5.5.380.0030.06020.55
5.5.370.0100.07720.46
5.5.360.0100.06020.45
5.5.350.0170.05720.47
5.5.340.0100.06021.03
5.5.330.0030.09021.02
5.5.320.0030.09020.99
5.5.310.0100.08321.03
5.5.300.0070.04321.03
5.5.290.0030.09021.05
5.5.280.0070.07721.02
5.5.270.0100.05320.95
5.5.260.0130.04321.05
5.5.250.0100.06020.68
5.5.240.0070.07320.36
5.5.230.0130.07020.22
5.5.220.0070.08320.28
5.5.210.0130.03720.18
5.5.200.0170.07320.39
5.5.190.0130.08020.24
5.5.180.0100.07320.29
5.5.160.0200.06720.28
5.5.150.0100.07720.35
5.5.140.0070.05320.18
5.5.130.0070.03720.30
5.5.120.0030.04320.27
5.5.110.0030.08320.17
5.5.100.0100.08020.14
5.5.90.0100.07320.29
5.5.80.0170.06320.29
5.5.70.0070.04720.11
5.5.60.0030.04320.27
5.5.50.0030.06720.04
5.5.40.0030.04720.02
5.5.30.0130.07320.27
5.5.20.0100.08020.27
5.5.10.0070.08320.27
5.5.00.0100.08020.13
5.4.450.0100.07719.61
5.4.440.0030.04719.56
5.4.430.0130.06719.58
5.4.420.0130.04019.55
5.4.410.0070.07019.30
5.4.400.0070.06319.21
5.4.390.0030.07019.11
5.4.380.0100.07319.25
5.4.370.0030.04719.26
5.4.360.0030.08019.29
5.4.350.0070.04719.35
5.4.340.0070.07719.30
5.4.320.0100.07019.29
5.4.310.0070.04319.11
5.4.300.0100.05019.26
5.4.290.0100.04319.04
5.4.280.0070.08018.95
5.4.270.0070.07719.27
5.4.260.0100.06019.04
5.4.250.0070.07319.12
5.4.240.0230.06319.24
5.4.230.0070.05019.23
5.4.220.0100.07719.14
5.4.210.0000.05318.93
5.4.200.0130.06719.36
5.4.190.0070.04319.25
5.4.180.0100.06319.07
5.4.170.0100.07319.22
5.4.160.0100.04719.09
5.4.150.0000.08019.21
5.4.140.0100.06016.50
5.4.130.0170.07016.57
5.4.120.0170.06316.54
5.4.110.0100.07016.59
5.4.100.0000.04316.61
5.4.90.0200.06016.77
5.4.80.0000.05716.51
5.4.70.0170.07716.57
5.4.60.0030.05016.58
5.4.50.0130.06016.55
5.4.40.0100.07316.66
5.4.30.0030.07016.57
5.4.20.0100.07016.73
5.4.10.0100.04016.53
5.4.00.0100.06715.96
5.3.290.0130.06714.91
5.3.280.0070.04014.64
5.3.270.0030.05714.84
5.3.260.0070.07714.87
5.3.250.0000.08714.80
5.3.240.0100.06714.76
5.3.230.0070.06714.88
5.3.220.0070.07314.72
5.3.210.0030.05314.71
5.3.200.0100.04014.72
5.3.190.0070.07714.81
5.3.180.0070.06314.75
5.3.170.0070.05014.75
5.3.160.0130.06714.85
5.3.150.0130.04714.72
5.3.140.0070.07314.79
5.3.130.0100.07314.83
5.3.120.0100.03714.77
5.3.110.0100.04014.71
5.3.100.0170.04014.28
5.3.90.0030.08314.20
5.3.80.0000.04314.17
5.3.70.0100.06014.17
5.3.60.0100.03714.25
5.3.50.0070.06014.11
5.3.40.0070.07314.11
5.3.30.0170.06013.91
5.3.20.0030.07013.78
5.3.10.0030.07013.79
5.3.00.0100.07313.64
5.2.170.0070.05711.28
5.2.160.0100.03011.30
5.2.150.0070.03011.30
5.2.140.0030.03311.14
5.2.130.0030.04711.34
5.2.120.0070.06011.29
5.2.110.0030.04311.25
5.2.100.0030.06311.09
5.2.90.0030.06711.25
5.2.80.0030.04711.18
5.2.70.0000.06711.29
5.2.60.0130.05311.05
5.2.50.0070.04311.11
5.2.40.0100.04711.23
5.2.30.0000.06010.97
5.2.20.0070.04311.13
5.2.10.0130.04311.05
5.2.00.0030.06010.95
5.1.60.0130.04310.16
5.1.50.0030.05010.07
5.1.40.0030.05310.17
5.1.30.0070.02310.38
5.1.20.0100.02310.58
5.1.10.0030.0309.93
5.1.00.0030.0279.97
5.0.50.0100.0378.64
5.0.40.0000.0478.52
5.0.30.0070.0438.32
5.0.20.0030.0408.36
5.0.10.0000.0338.28
5.0.00.0000.0508.28
4.4.90.0070.0337.95
4.4.80.0000.0407.95
4.4.70.0030.0137.95
4.4.60.0000.0307.95
4.4.50.0000.0277.95
4.4.40.0030.0407.95
4.4.30.0000.0377.95
4.4.20.0030.0177.95
4.4.10.0000.0177.95
4.4.00.0030.0277.95
4.3.110.0030.0337.95
4.3.100.0000.0337.95
4.3.90.0030.0277.95
4.3.80.0000.0537.95
4.3.70.0070.0307.95
4.3.60.0030.0237.95
4.3.50.0130.0237.95
4.3.40.0000.0277.95
4.3.30.0000.0277.95
4.3.20.0070.0277.95
4.3.10.0030.0207.95
4.3.00.0000.0207.95

preferences:
46.15 ms | 401 KiB | 5 Q