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)) { return new self($this->xml[$offset]->asXML(), false); } var_dump($this->xml->$offset->asXML()); 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']; var_dump((string)$xml->getIterator()->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.0120.00317.24
8.3.50.0220.00718.58
8.3.40.0060.01519.07
8.3.30.0100.01018.89
8.3.20.0040.00418.86
8.3.10.0040.00420.80
8.3.00.0040.00419.51
8.2.180.0070.01025.92
8.2.170.0120.00319.25
8.2.160.0060.00922.96
8.2.150.0030.00724.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0060.00321.07
8.2.110.0040.00421.15
8.2.100.0000.01218.09
8.2.90.0000.00919.58
8.2.80.0040.00419.34
8.2.70.0110.00017.75
8.2.60.0050.00318.05
8.2.50.0090.00018.07
8.2.40.0000.00718.28
8.2.30.0040.00818.41
8.2.20.0060.00319.64
8.2.10.0000.00817.90
8.2.00.0000.00817.89
8.1.280.0170.00025.92
8.1.270.0060.00323.99
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0030.00622.71
8.1.230.0070.00421.13
8.1.220.0000.00818.02
8.1.210.0040.00419.28
8.1.200.0060.00317.73
8.1.190.0040.00417.90
8.1.180.0050.00518.10
8.1.170.0040.00418.91
8.1.160.0040.00419.13
8.1.150.0090.00018.95
8.1.140.0000.00817.72
8.1.130.0080.00017.98
8.1.120.0090.00017.80
8.1.110.0030.00517.56
8.1.100.0040.00417.66
8.1.90.0080.00017.72
8.1.80.0000.00817.70
8.1.70.0000.00717.66
8.1.60.0040.00717.79
8.1.50.0030.00517.72
8.1.40.0000.00917.84
8.1.30.0040.00417.78
8.1.20.0000.00917.97
8.1.10.0040.00417.81
8.1.00.0000.00817.82
8.0.300.0040.00420.29
8.0.290.0040.00417.00
8.0.280.0070.00018.71
8.0.270.0000.00717.51
8.0.260.0000.00717.09
8.0.250.0040.00417.09
8.0.240.0030.00617.25
8.0.230.0080.00017.21
8.0.220.0000.00717.05
8.0.210.0070.00017.12
8.0.200.0000.00617.10
8.0.190.0000.00917.10
8.0.180.0040.00417.09
8.0.170.0090.00017.11
8.0.160.0030.00317.16
8.0.150.0000.01017.06
8.0.140.0000.01117.08
8.0.130.0000.00613.53
8.0.120.0090.00017.23
8.0.110.0000.00717.01
8.0.100.0040.00417.05
8.0.90.0040.00417.16
8.0.80.0030.01317.07
8.0.70.0050.00317.08
8.0.60.0040.00417.07
8.0.50.0050.00517.05
8.0.30.0100.00617.10
8.0.20.0080.01117.38
8.0.10.0080.00017.15
8.0.00.0110.01016.96
7.4.330.0000.00513.20
7.4.320.0030.00316.73
7.4.300.0040.00416.73
7.4.290.0030.00316.71
7.4.280.0000.00716.74
7.4.270.0030.00316.76
7.4.260.0060.00013.52
7.4.250.0040.00416.61
7.4.240.0030.00316.89
7.4.230.0020.00516.48
7.4.220.0130.00616.74
7.4.210.0120.00916.79
7.4.200.0050.00316.73
7.4.190.0040.00416.98
7.4.160.0080.00816.83
7.4.150.0100.01316.70
7.4.140.0070.01016.79
7.4.130.0030.01316.81
7.4.120.0110.00716.78
7.4.110.0100.00716.87
7.4.100.0140.00416.78
7.4.90.0090.00916.83
7.4.80.0120.00616.68
7.4.70.0040.01516.82
7.4.60.0100.00616.70
7.4.50.0030.00616.71
7.4.40.0070.00716.51
7.4.30.0060.01216.70
7.4.00.0100.00515.17
7.3.330.0060.00013.36
7.3.320.0000.00513.58
7.3.310.0070.00016.61
7.3.300.0030.00316.45
7.3.290.0060.00716.54
7.3.280.0080.01116.58
7.3.270.0140.01016.77
7.3.260.0070.01116.59
7.3.250.0180.00716.70
7.3.240.0100.00716.63
7.3.230.0100.00716.64
7.3.210.0140.00416.66
7.3.200.0120.00619.39
7.3.190.0070.01416.56
7.3.180.0090.00616.87
7.3.170.0110.00816.68
7.3.160.0100.00716.69
7.3.120.0080.00815.08
7.3.110.0090.00915.10
7.3.100.0000.01714.91
7.3.90.0060.00914.66
7.3.80.0070.01114.94
7.3.70.0040.01415.01
7.3.60.0070.01014.81
7.3.50.0060.00914.91
7.3.40.0100.00714.86
7.3.30.0070.00714.75
7.3.20.0000.01416.80
7.3.10.0000.00916.40
7.3.00.0080.00416.72
7.2.330.0090.00916.63
7.2.320.0060.01217.06
7.2.310.0060.01616.63
7.2.300.0140.00616.84
7.2.290.0070.01016.78
7.2.250.0070.01115.17
7.2.240.0060.00815.08
7.2.230.0110.00615.27
7.2.220.0090.00014.83
7.2.210.0100.01015.24
7.2.200.0040.01114.91
7.2.190.0070.01115.12
7.2.180.0060.01215.18
7.2.170.0030.01015.15
7.2.00.0000.01119.37
7.1.330.0090.00616.03
7.1.320.0040.00715.87
7.1.310.0070.01016.20
7.1.300.0090.00615.86
7.1.290.0100.00715.89
7.1.280.0030.01015.91
7.1.270.0030.01015.48
7.1.260.0090.00615.75
7.1.100.0140.00018.27
7.1.70.0060.00317.30
7.1.60.0160.00619.31
7.1.50.0060.00616.99
7.1.00.0000.07722.44
7.0.200.0000.00816.84
7.0.140.0130.06722.26
7.0.120.0000.04722.19
7.0.60.0070.07720.15
7.0.50.0070.04018.00
7.0.40.0070.05717.76
7.0.30.0130.07317.82
7.0.20.0100.07017.88
7.0.10.0030.08717.88
7.0.00.0030.05317.87
5.6.280.0100.06721.03
5.6.210.0070.07020.52
5.6.200.0030.08318.36
5.6.190.0030.08018.19
5.6.180.0100.07718.19
5.6.170.0100.08718.26
5.6.160.0000.04318.34
5.6.150.0000.04318.37
5.6.140.0030.04018.27
5.6.130.0000.04318.19
5.6.120.0070.03718.36
5.6.110.0000.04318.37
5.6.100.0030.04018.26
5.6.90.0030.04018.30
5.6.80.0000.04017.70
5.6.70.0030.03717.69
5.6.60.0030.03717.67
5.6.50.0070.03317.67
5.6.40.0030.03717.66
5.6.30.0030.03717.68
5.6.20.0030.03717.63
5.6.10.0070.03317.75
5.6.00.0000.04017.68
5.5.350.0330.07320.49
5.5.340.0170.04718.10
5.5.330.0030.08318.16
5.5.320.0070.05018.16
5.5.310.0070.07318.20
5.5.300.0000.04317.98
5.5.290.0070.03718.05
5.5.280.0070.03718.15
5.5.270.0070.03718.14
5.5.260.0000.04318.02
5.5.250.0030.03717.88
5.5.240.0070.03317.60
5.5.230.0000.04017.43
5.5.220.0000.04017.47
5.5.210.0030.03717.50
5.5.200.0000.04017.42
5.5.190.0000.04017.47
5.5.180.0070.03717.38
5.5.160.0000.04017.43
5.5.150.0000.04017.48
5.5.140.0000.04017.42
5.5.130.0070.03317.50
5.5.120.0070.08017.41
5.5.110.0030.08317.41
5.5.100.0070.07717.25
5.5.90.0030.06317.24
5.5.80.0070.06717.40
5.5.70.0000.06317.36
5.5.60.0070.06317.27
5.5.50.0100.06017.41
5.5.40.0030.04317.32
5.5.30.0030.06717.36
5.5.20.0030.07717.39
5.5.10.0100.06317.33
5.5.00.0030.08317.25
5.4.450.0030.04319.51
5.4.440.0100.03319.54
5.4.430.0000.04019.52
5.4.420.0030.03719.55
5.4.410.0000.04019.40
5.4.400.0030.03719.23
5.4.390.0070.03319.02
5.4.380.0000.04019.40
5.4.370.0030.03719.05
5.4.360.0030.03719.22
5.4.350.0030.03719.03
5.4.340.0030.03719.18
5.4.320.0130.03019.03
5.4.310.0000.04019.26
5.4.300.0030.03719.34
5.4.290.0070.04319.10
5.4.280.0100.03319.23
5.4.270.0000.05019.23
5.4.260.0030.07719.05
5.4.250.0030.07019.04
5.4.240.0030.07719.22
5.4.230.0030.06319.25
5.4.220.0070.07319.17
5.4.210.0070.04019.22
5.4.200.0000.07319.14
5.4.190.0030.07719.05
5.4.180.0030.04019.21
5.4.170.0070.08319.22
5.4.160.0030.07319.23
5.4.150.0030.06019.00
5.4.140.0070.05316.44
5.4.130.0030.07716.66
5.4.120.0200.05716.53
5.4.110.0030.04016.49
5.4.100.0130.06716.54
5.4.90.0030.06716.52
5.4.80.0030.07316.68
5.4.70.0030.07716.51
5.4.60.0100.07016.64
5.4.50.0000.07716.48
5.4.40.0070.06016.65
5.4.30.0030.06716.61
5.4.20.0100.03716.54
5.4.10.0030.08316.47
5.4.00.0030.07715.96
5.3.290.0000.04014.92
5.3.280.0130.06714.73
5.3.270.0030.04314.78
5.3.260.0030.05314.73
5.3.250.0070.07314.65
5.3.240.0030.07714.61
5.3.230.0030.05714.90
5.3.220.0070.04714.70
5.3.210.0030.04014.70
5.3.200.0100.05714.71
5.3.190.0100.04014.82
5.3.180.0030.08314.72
5.3.170.0030.07014.82
5.3.160.0000.07714.68
5.3.150.0030.06314.73
5.3.140.0100.07314.69
5.3.130.0100.07314.72
5.3.120.0070.08014.68
5.3.110.0070.07714.77
5.3.100.0030.05714.09
5.3.90.0100.07014.15
5.3.80.0130.06014.14
5.3.70.0100.07714.09
5.3.60.0030.05314.14
5.3.50.0100.07314.02
5.3.40.0100.05314.22
5.3.30.0070.06314.07
5.3.20.0030.07713.67
5.3.10.0000.04013.64
5.3.00.0100.05013.63
5.2.170.0030.06311.26
5.2.160.0100.05011.21
5.2.150.0000.07011.40
5.2.140.0000.07011.35
5.2.130.0100.04711.40
5.2.120.0070.04711.08
5.2.110.0070.03011.32
5.2.100.0030.06311.27
5.2.90.0000.05311.25
5.2.80.0000.04311.22
5.2.70.0030.06711.34
5.2.60.0030.06011.03
5.2.50.0030.04711.32
5.2.40.0030.03311.13
5.2.30.0000.03310.97
5.2.20.0000.05311.09
5.2.10.0000.03711.02
5.2.00.0030.03011.02
5.1.60.0100.03710.16
5.1.50.0070.04310.14
5.1.40.0070.02310.06
5.1.30.0030.05010.54
5.1.20.0030.03310.65
5.1.10.0100.03710.03
5.1.00.0030.04710.03
5.0.50.0070.0378.78
5.0.40.0070.0408.52
5.0.30.0070.0608.42
5.0.20.0030.0208.42
5.0.10.0030.0478.42
5.0.00.0070.0608.42
4.4.90.0070.0308.42
4.4.80.0000.0208.42
4.4.70.0070.0308.42
4.4.60.0030.0308.42
4.4.50.0000.0208.42
4.4.40.0030.0478.42
4.4.30.0070.0308.42
4.4.20.0000.0408.42
4.4.10.0000.0278.42
4.4.00.0000.0378.42
4.3.110.0030.0138.42
4.3.100.0000.0178.42
4.3.90.0070.0208.42
4.3.80.0030.0438.42
4.3.70.0000.0238.42
4.3.60.0030.0308.42
4.3.50.0100.0308.42
4.3.40.0030.0478.42
4.3.30.0000.0408.42
4.3.20.0030.0338.42
4.3.10.0030.0138.42
4.3.00.0000.0178.42

preferences:
46.31 ms | 401 KiB | 5 Q