3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $filePath; private $isUrl; 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 ($this->xml->$offset->count() > 1) { return new self($this->xml->$offset->asXML(), false); } return $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']; var_dump($xml['note']['to']->count()); //var_dump((string)$xml['note']['recursive']);

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.0040.01118.68
8.3.50.0140.00221.39
8.3.40.0040.01119.23
8.3.30.0130.00319.15
8.3.20.0000.00818.99
8.3.10.0060.00320.61
8.3.00.0070.00023.91
8.2.180.0140.00717.00
8.2.170.0070.01422.96
8.2.160.0090.00620.76
8.2.150.0100.01024.18
8.2.140.0030.00624.66
8.2.130.0070.00026.16
8.2.120.0080.00022.13
8.2.110.0050.00521.27
8.2.100.0090.00317.97
8.2.90.0060.00319.59
8.2.80.0040.00419.43
8.2.70.0060.00317.75
8.2.60.0030.00618.05
8.2.50.0040.00418.18
8.2.40.0030.00618.47
8.2.30.0040.00420.09
8.2.20.0030.00617.84
8.2.10.0040.00417.95
8.2.00.0000.00817.84
8.1.280.0100.00625.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0070.00322.72
8.1.230.0090.00321.15
8.1.220.0000.00817.79
8.1.210.0050.00319.10
8.1.200.0080.00317.61
8.1.190.0060.00317.73
8.1.180.0080.00018.10
8.1.170.0030.00519.07
8.1.160.0000.00819.01
8.1.150.0000.00818.92
8.1.140.0040.00417.68
8.1.130.0070.00018.04
8.1.120.0070.00017.60
8.1.110.0040.00417.63
8.1.100.0000.00817.63
8.1.90.0080.00017.71
8.1.80.0000.00717.68
8.1.70.0030.00317.70
8.1.60.0030.00517.86
8.1.50.0000.00817.65
8.1.40.0050.00317.66
8.1.30.0000.00817.78
8.1.20.0040.00417.84
8.1.10.0090.00017.73
8.1.00.0040.00417.82
8.0.300.0040.00420.16
8.0.290.0050.00317.00
8.0.280.0000.00718.65
8.0.270.0030.00317.41
8.0.260.0000.00716.99
8.0.250.0000.00717.18
8.0.240.0060.00317.14
8.0.230.0000.00717.05
8.0.220.0030.00317.06
8.0.210.0000.00717.04
8.0.200.0000.00717.20
8.0.190.0080.00017.11
8.0.180.0050.00317.10
8.0.170.0030.00517.05
8.0.160.0040.00417.06
8.0.150.0040.00417.08
8.0.140.0030.00516.94
8.0.130.0080.00013.61
8.0.120.0040.00417.12
8.0.110.0040.00417.23
8.0.100.0030.00516.97
8.0.90.0000.00717.14
8.0.80.0120.00317.14
8.0.70.0000.00717.13
8.0.60.0000.00817.17
8.0.50.0050.00217.12
8.0.30.0050.01417.43
8.0.20.0090.00917.40
8.0.10.0030.00517.17
8.0.00.0090.01016.98
7.4.330.0050.00014.96
7.4.320.0060.00016.75
7.4.300.0030.00316.74
7.4.290.0070.00016.79
7.4.280.0030.00516.75
7.4.270.0000.00816.67
7.4.260.0000.00613.36
7.4.250.0060.00316.81
7.4.240.0040.00416.70
7.4.230.0000.00716.91
7.4.220.0090.00916.58
7.4.210.0080.00916.81
7.4.200.0080.00016.76
7.4.190.0070.00016.84
7.4.160.0000.01716.58
7.4.150.0090.00917.40
7.4.140.0100.00717.86
7.4.130.0090.01016.87
7.4.120.0060.01116.60
7.4.110.0120.01216.72
7.4.100.0110.00716.90
7.4.90.0150.00616.84
7.4.80.0170.00019.04
7.4.70.0030.01916.69
7.4.60.0120.00616.68
7.4.50.0030.00316.50
7.4.40.0060.01022.27
7.4.30.0060.01016.90
7.4.00.0070.01115.02
7.3.330.0000.00513.34
7.3.320.0000.00513.48
7.3.310.0050.00216.62
7.3.300.0070.00016.57
7.3.290.0030.01516.58
7.3.280.0110.00716.53
7.3.270.0120.00617.40
7.3.260.0150.00418.24
7.3.250.0150.00316.67
7.3.240.0190.00416.80
7.3.230.0090.00916.82
7.3.210.0130.00316.89
7.3.200.0030.01919.39
7.3.190.0090.00916.90
7.3.180.0030.01316.81
7.3.170.0090.00916.57
7.3.160.0170.00316.59
7.3.120.0070.00814.97
7.3.110.0030.01614.75
7.3.100.0040.01515.20
7.3.90.0040.01115.17
7.3.80.0040.01215.01
7.3.70.0030.00614.97
7.3.60.0070.01114.82
7.3.50.0000.01414.79
7.3.40.0000.01014.92
7.3.30.0070.00714.76
7.3.20.0070.00716.79
7.3.10.0110.00416.82
7.3.00.0000.01016.93
7.2.330.0090.01417.09
7.2.320.0000.01716.98
7.2.310.0090.00916.98
7.2.300.0170.00716.95
7.2.290.0060.01117.03
7.2.250.0060.01115.40
7.2.240.0060.01015.15
7.2.230.0110.00415.23
7.2.220.0070.01015.32
7.2.210.0030.01015.17
7.2.200.0040.01515.25
7.2.190.0030.01315.40
7.2.180.0000.01415.06
7.2.170.0060.00615.13
7.2.160.0060.00315.27
7.2.150.0120.00417.02
7.2.140.0090.00316.97
7.2.130.0100.00317.15
7.2.120.0030.01017.25
7.2.110.0070.00717.07
7.2.100.0090.00916.92
7.2.90.0060.01116.98
7.2.80.0040.00717.02
7.2.70.0090.00617.29
7.2.60.0060.00617.13
7.2.50.0100.00316.81
7.2.40.0000.01217.07
7.2.30.0070.00717.19
7.2.20.0070.00717.00
7.2.10.0040.01417.22
7.2.00.0050.01218.28
7.1.330.0100.00716.11
7.1.320.0060.00915.94
7.1.310.0070.00715.75
7.1.300.0030.01215.88
7.1.290.0060.00315.86
7.1.280.0080.00815.99
7.1.270.0030.00715.73
7.1.260.0030.01015.86
7.1.250.0070.00715.83
7.1.240.0030.01015.70
7.1.230.0060.00616.10
7.1.220.0030.01315.77
7.1.210.0110.00316.01
7.1.200.0060.00615.81
7.1.190.0040.01115.92
7.1.180.0000.00816.01
7.1.170.0120.00315.93
7.1.160.0050.00515.70
7.1.150.0040.00415.82
7.1.140.0120.00315.95
7.1.130.0050.00515.89
7.1.120.0090.00616.03
7.1.110.0060.00616.03
7.1.100.0050.01017.19
7.1.90.0060.01215.71
7.1.80.0060.01215.81
7.1.70.0050.00716.57
7.1.60.0110.00817.63
7.1.50.0150.01025.52
7.1.40.0040.00416.04
7.1.30.0100.00016.02
7.1.20.0040.00716.09
7.1.10.0070.00715.93
7.1.00.0090.02719.13
7.0.330.0090.00015.29
7.0.320.0030.01315.54
7.0.310.0030.01015.47
7.0.300.0090.00915.72
7.0.290.0040.01115.29
7.0.280.0070.00715.59
7.0.270.0060.00915.43
7.0.260.0070.00315.53
7.0.250.0080.00315.64
7.0.240.0090.00615.52
7.0.230.0030.00615.63
7.0.220.0040.01115.55
7.0.210.0070.00315.56
7.0.200.0040.00816.05
7.0.190.0070.00615.32
7.0.180.0100.00015.73
7.0.170.0040.00715.62
7.0.160.0060.01015.46
7.0.150.0000.01115.55
7.0.140.0050.03918.79
7.0.130.0090.00315.66
7.0.120.0000.01815.65
7.0.110.0040.01115.55
7.0.100.0040.00415.27
7.0.90.0040.00815.45
7.0.80.0060.00615.67
7.0.70.0100.00315.51
7.0.60.0000.03217.72
7.0.50.0070.02916.64
7.0.40.0110.03015.84
7.0.30.0070.02815.67
7.0.20.0050.04015.77
7.0.10.0070.04215.59
7.0.00.0050.02415.84
5.6.400.0030.00614.44
5.6.390.0000.01314.48
5.6.380.0070.01014.30
5.6.370.0060.00614.17
5.6.360.0100.00314.47
5.6.350.0070.00714.45
5.6.340.0030.00614.47
5.6.330.0100.00714.31
5.6.320.0060.00914.60
5.6.310.0030.01314.87
5.6.300.0060.00614.66
5.6.290.0080.00614.32
5.6.280.0010.04317.92
5.6.270.0060.00614.68
5.6.260.0100.00314.47
5.6.250.0030.00914.53
5.6.240.0040.00414.36
5.6.230.0030.01014.66
5.6.220.0040.00414.62
5.6.210.0070.04617.62
5.6.200.0070.04116.57
5.6.190.0040.04216.40
5.6.180.0050.04616.30
5.6.170.0060.03816.64
5.6.160.0110.03816.35
5.6.150.0110.04216.59
5.6.140.0030.02516.32
5.6.130.0070.04316.38
5.6.120.0050.02316.33
5.6.110.0020.02716.52
5.6.100.0050.02316.43
5.6.90.0030.02716.41
5.6.80.0050.02116.07
5.6.70.0070.01916.13
5.6.60.0080.02016.02
5.6.50.0020.02516.09
5.6.40.0020.02416.10
5.6.30.0030.02315.98
5.6.20.0020.02515.89
5.6.10.0020.02316.07
5.6.00.0050.02516.19
5.5.380.0000.01514.67
5.5.370.0050.00514.64
5.5.360.0030.00614.45
5.5.350.0030.04317.41
5.5.340.0050.03016.33
5.5.330.0120.03516.37
5.5.320.0040.04616.29
5.5.310.0060.04116.35
5.5.300.0070.03916.25
5.5.290.0120.03816.28
5.5.280.0090.02116.25
5.5.270.0040.02716.37
5.5.260.0050.02016.32
5.5.250.0020.02416.26
5.5.240.0060.01915.98
5.5.230.0020.02315.99
5.5.220.0020.02815.93
5.5.210.0100.02016.04
5.5.200.0050.02215.73
5.5.190.0040.02215.96
5.5.180.0070.01815.99
5.5.170.0080.00414.52
5.5.160.0020.02316.02
5.5.150.0050.02315.84
5.5.140.0030.02316.04
5.5.130.0030.02415.99
5.5.120.0050.02015.77
5.5.110.0050.02715.95
5.5.100.0030.02316.04
5.5.90.0030.02316.03
5.5.80.0040.02015.82
5.5.70.0030.02515.74
5.5.60.0050.02215.79
5.5.50.0080.03716.05
5.5.40.0030.03115.81
5.5.30.0110.02815.78
5.5.20.0040.03015.77
5.5.10.0080.02215.92
5.5.00.0060.02615.96
5.4.450.0060.03616.08
5.4.440.0040.02216.01
5.4.430.0050.02216.11
5.4.420.0030.02316.09
5.4.410.0080.01715.95
5.4.400.0030.02315.91
5.4.390.0030.02515.85
5.4.380.0090.01715.89
5.4.370.0050.02415.80
5.4.360.0080.01715.93
5.4.350.0050.02415.95
5.4.340.0070.01815.92
5.4.330.0000.00912.64
5.4.320.0130.01815.89
5.4.310.0040.02115.96
5.4.300.0080.01815.94
5.4.290.0060.01815.91
5.4.280.0020.02415.83
5.4.270.0020.02815.88
5.4.260.0000.02615.85
5.4.250.0030.02115.85
5.4.240.0030.02215.93
5.4.230.0040.02215.89
5.4.220.0050.03015.92
5.4.210.0020.02615.91
5.4.200.0020.02815.92
5.4.190.0050.04215.84
5.4.180.0050.02915.93
5.4.170.0050.02315.93
5.4.160.0130.02715.79
5.4.150.0030.02515.92
5.4.140.0050.03814.61
5.4.130.0020.04014.59
5.4.120.0090.03514.54
5.4.110.0010.02814.57
5.4.100.0040.03914.58
5.4.90.0030.04014.67
5.4.80.0010.03714.56
5.4.70.0020.02414.66
5.4.60.0020.02414.69
5.4.50.0050.02214.58
5.4.40.0080.02014.64
5.4.30.0100.03514.57
5.4.20.0060.04214.63
5.4.10.0100.02514.66
5.4.00.0030.03314.32
5.3.290.0020.02713.72
5.3.280.0050.02113.64
5.3.270.0080.03913.70
5.3.260.0030.04013.70
5.3.250.0030.03513.70
5.3.240.0070.03913.69
5.3.230.0090.03513.64
5.3.220.0000.04413.66
5.3.210.0050.02513.69
5.3.200.0000.02913.69
5.3.190.0070.04113.73
5.3.180.0050.03113.69
5.3.170.0060.03813.75
5.3.160.0050.02213.63
5.3.150.0020.02313.69
5.3.140.0070.04313.63
5.3.130.0050.04213.65
5.3.120.0110.03813.72
5.3.110.0040.02913.62
5.3.100.0000.04213.42
5.3.90.0060.02313.43
5.3.80.0050.02113.39
5.3.70.0060.03913.39
5.3.60.0070.04013.39
5.3.50.0070.03713.37
5.3.40.0050.02513.37
5.3.30.0120.01913.40
5.3.20.0050.03613.31
5.3.10.0050.04013.18
5.3.00.0080.03413.21
5.2.170.0070.04711.41
5.2.160.0030.06311.27
5.2.150.0130.03011.22
5.2.140.0000.06711.29
5.2.130.0100.05711.12
5.2.120.0030.05011.12
5.2.110.0100.05011.35
5.2.100.0070.03011.27
5.2.90.0100.05711.23
5.2.80.0070.05711.21
5.2.70.0100.04711.21
5.2.60.0070.05711.12
5.2.50.0030.04711.15
5.2.40.0100.03311.21
5.2.30.0070.05311.14
5.2.20.0070.06311.26
5.2.10.0170.03711.12
5.2.00.0000.04011.12
5.1.60.0100.03711.12
5.1.50.0030.05311.12
5.1.40.0000.06011.12
5.1.30.0130.04711.12
5.1.20.0030.04711.12
5.1.10.0170.04311.12
5.1.00.0030.05311.12
5.0.50.0030.04011.12
5.0.40.0000.04711.12
5.0.30.0000.06011.12
5.0.20.0030.04711.12
5.0.10.0100.03711.12
5.0.00.0070.05311.12
4.4.90.0000.03711.12
4.4.80.0070.03011.12
4.4.70.0070.03711.12
4.4.60.0030.03311.12
4.4.50.0000.03011.12
4.4.40.0000.05711.12
4.4.30.0000.04011.12
4.4.20.0030.03311.12
4.4.10.0030.03711.12
4.4.00.0000.06011.12
4.3.110.0000.02711.12
4.3.100.0030.04011.12
4.3.90.0000.03711.12
4.3.80.0000.05711.12
4.3.70.0000.03311.12
4.3.60.0070.03011.12
4.3.50.0030.03311.12
4.3.40.0000.05311.12
4.3.30.0030.03311.12
4.3.20.0000.03311.12
4.3.10.0000.02711.12
4.3.00.0000.03711.12

preferences:
49.29 ms | 401 KiB | 5 Q