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); $target = $target[$offset]; return new self($target->asXML(), false); } if ('val1' == $offset) { var_dump((array)$this->xml->$offset);die; } var_dump($this->xml->$offset); return (array) $this->xml->$offset;//new self($this->xml->$offset->asXML(), false); } public function __toString() { return (string) $this->xml->$offset; } 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']; echo $xml['note']['recursive']['val'];

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.0140.00718.70
8.3.50.0130.00521.39
8.3.40.0000.01419.23
8.3.30.0000.01520.56
8.3.20.0040.00420.37
8.3.10.0040.00422.08
8.3.00.0000.00822.60
8.2.180.0120.00917.13
8.2.170.0120.00322.96
8.2.160.0140.00020.70
8.2.150.0040.00424.18
8.2.140.0030.00724.66
8.2.130.0050.00226.16
8.2.120.0040.00420.90
8.2.110.0090.00022.28
8.2.100.0120.00019.76
8.2.90.0040.00419.66
8.2.80.0000.00819.57
8.2.70.0030.00617.59
8.2.60.0090.00018.05
8.2.50.0060.00318.07
8.2.40.0040.00418.53
8.2.30.0070.00019.53
8.2.20.0040.00417.93
8.2.10.0030.00617.90
8.2.00.0040.00418.08
8.1.280.0070.01425.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00720.34
8.1.230.0000.01217.95
8.1.220.0030.00518.03
8.1.210.0030.00518.77
8.1.200.0040.00417.50
8.1.190.0050.00317.66
8.1.180.0000.00818.10
8.1.170.0040.00418.77
8.1.160.0040.00419.01
8.1.150.0050.00318.85
8.1.140.0040.00417.75
8.1.130.0000.00818.03
8.1.120.0000.00717.64
8.1.110.0050.00317.68
8.1.100.0040.00417.63
8.1.90.0000.00717.62
8.1.80.0040.00417.59
8.1.70.0030.00317.63
8.1.60.0040.00417.77
8.1.50.0000.00817.71
8.1.40.0080.00417.62
8.1.30.0000.00817.84
8.1.20.0000.00817.97
8.1.10.0030.00617.68
8.1.00.0020.00517.72
8.0.300.0020.00518.77
8.0.290.0000.00717.41
8.0.280.0030.00318.53
8.0.270.0070.00017.30
8.0.260.0000.00717.08
8.0.250.0030.00317.13
8.0.240.0040.00417.22
8.0.230.0000.00817.17
8.0.220.0040.00417.11
8.0.210.0040.00417.12
8.0.200.0030.00317.18
8.0.190.0000.00817.12
8.0.180.0030.00517.22
8.0.170.0030.00617.12
8.0.160.0000.00717.11
8.0.150.0050.00317.13
8.0.140.0000.00817.09
8.0.130.0000.00613.61
8.0.120.0040.00417.02
8.0.110.0050.00217.05
8.0.100.0080.00017.18
8.0.90.0000.00817.09
8.0.80.0080.00817.09
8.0.70.0040.00417.02
8.0.60.0040.00417.21
8.0.50.0030.00517.21
8.0.30.0130.00617.22
8.0.20.0120.00817.42
8.0.10.0000.00817.30
8.0.00.0060.01516.98
7.4.330.0000.00516.81
7.4.320.0050.00316.73
7.4.300.0000.00716.69
7.4.290.0030.00516.68
7.4.280.0000.00716.72
7.4.270.0070.00016.70
7.4.260.0030.00313.45
7.4.250.0040.00416.80
7.4.240.0050.00216.73
7.4.230.0040.00416.90
7.4.220.0120.00616.85
7.4.210.0090.00616.72
7.4.200.0000.00816.84
7.4.190.0030.00316.92
7.4.160.0100.00716.66
7.4.150.0080.00917.40
7.4.140.0120.00417.86
7.4.130.0110.00816.71
7.4.120.0080.00916.88
7.4.110.0060.01116.63
7.4.100.0100.00716.92
7.4.90.0090.00916.94
7.4.80.0090.00919.39
7.4.70.0060.00916.72
7.4.60.0070.01016.97
7.4.50.0080.00016.66
7.4.40.0040.00822.77
7.4.30.0150.00316.98
7.4.00.0080.00815.08
7.3.330.0000.00513.38
7.3.320.0060.00013.57
7.3.310.0030.00316.54
7.3.300.0050.00216.57
7.3.290.0090.00616.59
7.3.280.0030.01516.62
7.3.270.0170.00017.40
7.3.260.0070.01016.64
7.3.250.0100.01116.71
7.3.240.0100.00716.88
7.3.230.0100.00716.65
7.3.210.0080.01116.66
7.3.200.0090.00919.39
7.3.190.0090.01016.67
7.3.180.0090.00616.76
7.3.170.0060.00916.87
7.3.160.0030.02016.71
7.3.120.0000.01214.69
7.2.330.0120.00616.96
7.2.320.0130.01017.01
7.2.310.0090.00916.84
7.2.300.0120.00916.78
7.2.290.0090.00916.70
7.2.60.0080.00417.11
7.1.200.0060.00615.88
7.1.100.0040.00818.09
7.1.70.0000.01017.32
7.1.60.0000.02319.17
7.1.50.0080.00417.01
7.1.00.0000.08022.61
7.0.200.0000.00816.82
7.0.140.0030.07022.20
7.0.100.0170.07319.97
7.0.90.0100.07019.94
7.0.80.0070.07320.07
7.0.70.0100.07020.04
7.0.60.0070.08319.93
7.0.50.0130.08020.34
7.0.40.0030.08720.16
7.0.30.0200.06720.23
7.0.20.0130.04720.10
7.0.10.0030.09020.04
7.0.00.0070.05020.12
5.6.280.0030.07021.07
5.6.250.0130.07021.00
5.6.240.0030.06020.81
5.6.230.0030.08720.68
5.6.220.0070.08720.55
5.6.210.0130.07720.87
5.6.200.0130.08021.25
5.6.190.0170.07321.09
5.6.180.0070.07321.12
5.6.170.0130.08021.19
5.6.160.0100.07721.14
5.6.150.0170.07721.23
5.6.140.0070.08720.99
5.6.130.0170.07721.06
5.6.120.0170.07721.07
5.6.110.0100.08321.09
5.6.100.0070.05321.11
5.6.90.0070.07721.04
5.6.80.0000.08020.38
5.6.70.0130.07020.57
5.6.60.0030.06720.50
5.6.50.0230.06320.38
5.6.40.0100.08320.39
5.6.30.0070.07720.44
5.6.20.0100.07720.37
5.6.10.0230.06020.51
5.6.00.0130.07020.41
5.5.380.0100.08020.63
5.5.370.0170.07020.60
5.5.360.0070.05020.60
5.5.350.0030.09020.49
5.5.340.0100.08021.04
5.5.330.0130.06720.78
5.5.320.0070.06721.06
5.5.310.0100.08020.81
5.5.300.0100.08320.75
5.5.290.0000.09020.85
5.5.280.0100.08321.03
5.5.270.0030.08720.81
5.5.260.0070.07020.98
5.5.250.0100.08020.83
5.5.240.0030.08720.33
5.5.230.0070.08720.23
5.5.220.0000.08020.32
5.5.210.0130.07320.30
5.5.200.0070.06720.18
5.5.190.0100.07020.36
5.5.180.0030.08320.40
5.5.160.0070.07320.14
5.5.150.0070.07320.30
5.5.140.0070.08020.19
5.5.130.0100.07720.24
5.5.120.0100.04320.24
5.5.110.0070.06320.26
5.5.100.0130.06720.10
5.5.90.0070.07720.06
5.5.80.0000.04320.18
5.5.70.0070.07320.11
5.5.60.0070.05320.11
5.5.50.0130.07720.24
5.5.40.0130.07020.11
5.5.30.0070.08020.15
5.5.20.0130.07320.11
5.5.10.0000.06320.21
5.5.00.0070.08020.08
5.4.450.0100.08019.46
5.4.440.0100.07019.56
5.4.430.0030.08019.61
5.4.420.0130.07319.58
5.4.410.0130.07319.22
5.4.400.0130.07319.24
5.4.390.0030.06019.04
5.4.380.0100.07019.28
5.4.370.0030.07719.25
5.4.360.0030.07319.26
5.4.350.0070.07319.03
5.4.340.0070.07319.15
5.4.320.0100.04319.23
5.4.310.0030.04019.11
5.4.300.0130.06718.92
5.4.290.0070.07319.28
5.4.280.0030.07719.09
5.4.270.0130.07019.36
5.4.260.0070.08019.10
5.4.250.0130.07019.22
5.4.240.0030.04319.25
5.4.230.0070.07319.23
5.4.220.0070.06718.91
5.4.210.0200.06018.95
5.4.200.0100.07019.10
5.4.190.0070.07319.23
5.4.180.0030.04718.94
5.4.170.0030.08318.91
5.4.160.0070.07318.93
5.4.150.0030.08319.02
5.4.140.0070.07316.59
5.4.130.0170.06316.64
5.4.120.0070.09016.37
5.4.110.0100.05016.59
5.4.100.0000.08016.59
5.4.90.0070.04316.52
5.4.80.0070.07016.60
5.4.70.0070.06316.46
5.4.60.0100.06716.54
5.4.50.0030.06316.62
5.4.40.0070.07016.66
5.4.30.0130.06316.56
5.4.20.0070.07316.50
5.4.10.0030.07316.45
5.4.00.0000.07715.99
5.3.290.0070.06314.71
5.3.280.0030.06714.82
5.3.270.0030.08014.70
5.3.260.0030.07314.63
5.3.250.0170.06314.79
5.3.240.0070.06714.76
5.3.230.0030.07314.61
5.3.220.0030.07714.76
5.3.210.0030.08314.70
5.3.200.0130.07014.79
5.3.190.0070.07314.72
5.3.180.0030.07714.59
5.3.170.0070.07714.79
5.3.160.0070.07314.79
5.3.150.0070.06314.70
5.3.140.0070.07314.71
5.3.130.0100.06714.57
5.3.120.0130.06714.74
5.3.110.0100.06714.71
5.3.100.0070.04314.17
5.3.90.0100.07314.16
5.3.80.0070.06714.29
5.3.70.0130.06714.25
5.3.60.0000.08014.09
5.3.50.0030.07314.18
5.3.40.0030.07013.97
5.3.30.0070.07314.00
5.3.20.0100.05713.71
5.3.10.0100.04013.84
5.3.00.0070.06713.64
5.2.170.0070.05711.28
5.2.160.0000.06311.27
5.2.150.0030.06311.29
5.2.140.0030.06711.29
5.2.130.0000.06311.08
5.2.120.0070.05711.32
5.2.110.0000.07011.34
5.2.100.0100.05311.25
5.2.90.0000.06311.11
5.2.80.0100.05311.10
5.2.70.0000.06011.32
5.2.60.0170.04011.28
5.2.50.0000.04011.02
5.2.40.0030.06011.07
5.2.30.0170.05311.06
5.2.20.0170.02311.14
5.2.10.0000.06710.94
5.2.00.0030.05710.72
5.1.60.0070.05010.02
5.1.50.0030.03310.09
5.1.40.0000.05710.19
5.1.30.0100.05010.60
5.1.20.0000.05710.37
5.1.10.0100.04010.18
5.1.00.0070.05010.20
5.0.50.0030.04310.02
5.0.40.0070.04310.02
5.0.30.0100.06010.02
5.0.20.0030.03310.02
5.0.10.0000.03310.02
5.0.00.0070.05710.02
4.4.90.0030.03710.02
4.4.80.0030.03310.02
4.4.70.0000.03710.02
4.4.60.0070.03010.02
4.4.50.0000.03710.02
4.4.40.0000.05710.02
4.4.30.0000.03310.02
4.4.20.0070.03010.02
4.4.10.0070.03010.02
4.4.00.0030.05310.02
4.3.110.0030.03310.02
4.3.100.0000.03710.02
4.3.90.0030.02010.02
4.3.80.0070.04010.02
4.3.70.0000.03310.02
4.3.60.0000.03710.02
4.3.50.0000.03310.02
4.3.40.0070.03310.02
4.3.30.0000.03710.02
4.3.20.0030.03710.02
4.3.10.0070.02710.02
4.3.00.0000.03710.02

preferences:
49.98 ms | 401 KiB | 5 Q