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; } return (array) $this->xml->$offset;//new self($this->xml->$offset->asXML(), false); } public function __toString() { die; 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); var_dump($xml['note']['to']); echo $xml['note']['to']; echo $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.0110.00318.56
8.3.50.0110.00917.78
8.3.40.0100.01019.08
8.3.30.0040.01119.01
8.3.20.0080.00019.15
8.3.10.0060.00320.61
8.3.00.0000.00817.88
8.2.180.0070.00716.88
8.2.170.0070.00722.96
8.2.160.0000.01519.07
8.2.150.0040.00424.18
8.2.140.0020.00524.66
8.2.130.0000.00826.16
8.2.120.0070.00020.01
8.2.110.0050.00521.20
8.2.100.0040.00817.97
8.2.90.0100.00019.46
8.2.80.0040.00418.18
8.2.70.0080.00317.72
8.2.60.0030.00518.18
8.2.50.0030.00618.07
8.2.40.0050.00320.32
8.2.30.0080.00018.43
8.2.20.0000.00818.09
8.2.10.0040.00417.95
8.2.00.0080.00318.17
8.1.280.0070.00725.92
8.1.270.0120.00624.66
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0000.01121.04
8.1.230.0040.00820.99
8.1.220.0040.00417.79
8.1.210.0040.00419.14
8.1.200.0040.00417.60
8.1.190.0000.00817.78
8.1.180.0070.00318.10
8.1.170.0080.00019.05
8.1.160.0020.00519.04
8.1.150.0050.00318.93
8.1.140.0040.00417.72
8.1.130.0030.00317.95
8.1.120.0000.00717.64
8.1.110.0080.00317.52
8.1.100.0050.00317.69
8.1.90.0000.00717.68
8.1.80.0080.00017.64
8.1.70.0000.00717.73
8.1.60.0050.00317.79
8.1.50.0050.00317.63
8.1.40.0000.00817.70
8.1.30.0040.00417.84
8.1.20.0030.00517.76
8.1.10.0030.00617.84
8.1.00.0040.00417.70
8.0.300.0000.00719.93
8.0.290.0000.00717.00
8.0.280.0040.00418.73
8.0.270.0040.00417.32
8.0.260.0000.00818.73
8.0.250.0030.00517.29
8.0.240.0040.00417.18
8.0.230.0080.00017.31
8.0.220.0000.00717.18
8.0.210.0000.00717.18
8.0.200.0000.00717.26
8.0.190.0040.00417.08
8.0.180.0040.00417.16
8.0.170.0040.00417.16
8.0.160.0020.00517.10
8.0.150.0050.00317.18
8.0.140.0080.00017.11
8.0.130.0000.00613.64
8.0.120.0040.00417.10
8.0.110.0080.00017.18
8.0.100.0000.00717.24
8.0.90.0000.00917.08
8.0.80.0110.00617.24
8.0.70.0000.00816.94
8.0.60.0050.00317.18
8.0.50.0000.00817.07
8.0.30.0090.01017.42
8.0.20.0110.00817.19
8.0.10.0000.00717.42
8.0.00.0090.01416.92
7.4.330.0050.00014.99
7.4.320.0030.00316.74
7.4.300.0050.00316.67
7.4.290.0000.00716.70
7.4.280.0030.00616.75
7.4.270.0060.00316.83
7.4.260.0060.00013.52
7.4.250.0090.00016.72
7.4.240.0040.00416.67
7.4.230.0000.00816.71
7.4.220.0070.01416.63
7.4.210.0090.01016.68
7.4.200.0030.00516.81
7.4.190.0030.00316.50
7.4.160.0100.00616.75
7.4.150.0110.00717.07
7.4.140.0080.00917.26
7.4.130.0100.00816.74
7.4.120.0060.01116.58
7.4.110.0150.00616.71
7.4.100.0100.01116.70
7.4.90.0070.01016.93
7.4.80.0090.00918.80
7.4.70.0090.00916.91
7.4.60.0170.00416.79
7.4.50.0050.00016.45
7.4.40.0060.01222.26
7.4.30.0080.01116.79
7.4.00.0070.01014.91
7.3.330.0040.00413.61
7.3.320.0000.00613.40
7.3.310.0000.00916.61
7.3.300.0070.00016.59
7.3.290.0180.00416.61
7.3.280.0100.00816.59
7.3.270.0140.00317.07
7.3.260.0140.00718.24
7.3.250.0120.00816.77
7.3.240.0150.00316.80
7.3.230.0170.00016.90
7.3.210.0120.00616.60
7.3.200.0100.00719.39
7.3.190.0100.01216.71
7.3.180.0120.00416.82
7.3.170.0100.00716.61
7.3.160.0060.01016.68
7.3.120.0030.01414.84
7.3.110.0070.01014.86
7.3.100.0070.00714.75
7.3.90.0100.00315.04
7.3.80.0040.00414.67
7.3.70.0030.00814.86
7.3.60.0030.00614.90
7.3.50.0000.01114.84
7.3.40.0100.00314.71
7.3.30.0030.00714.71
7.3.20.0070.00716.95
7.3.10.0060.01016.81
7.3.00.0080.00616.83
7.2.330.0110.00816.93
7.2.320.0090.01317.07
7.2.310.0110.00717.02
7.2.300.0110.00616.87
7.2.290.0120.00616.96
7.2.250.0090.00615.18
7.2.240.0070.00715.03
7.2.230.0060.00915.16
7.2.220.0040.00815.03
7.2.210.0040.00715.02
7.2.200.0080.00015.12
7.2.190.0000.01415.09
7.2.180.0030.00915.41
7.2.170.0040.00415.30
7.2.160.0060.01015.12
7.2.150.0070.01017.01
7.2.140.0070.00717.02
7.2.130.0050.00916.97
7.2.120.0030.00917.17
7.2.110.0060.00916.97
7.2.100.0080.00516.92
7.2.90.0050.00917.05
7.2.80.0060.00817.00
7.2.70.0050.00816.97
7.2.60.0060.00617.00
7.2.50.0040.01017.02
7.2.40.0060.00517.04
7.2.30.0070.00816.96
7.2.20.0070.00717.24
7.2.10.0040.00816.97
7.2.00.0050.00917.64
7.1.330.0060.00816.02
7.1.320.0070.00715.61
7.1.310.0060.00615.82
7.1.300.0040.01115.59
7.1.290.0060.00815.66
7.1.280.0030.00615.72
7.1.270.0030.01315.95
7.1.260.0040.01415.85
7.1.250.0010.01215.92
7.1.100.0030.01218.45
7.1.70.0050.00317.16
7.1.60.0160.00919.40
7.1.50.0040.01917.18
7.1.00.0070.07322.43
7.0.200.0040.00417.00
7.0.140.0100.06722.05
7.0.120.0030.03022.20
7.0.60.0170.05320.03
7.0.50.0070.08018.04
7.0.40.0000.04720.47
7.0.30.0200.08720.33
7.0.20.0230.05020.22
7.0.10.0030.04720.33
7.0.00.0100.03720.18
5.6.280.0070.07020.94
5.6.210.0130.05720.67
5.6.200.0130.04718.30
5.6.190.0070.04720.74
5.6.180.0200.04720.55
5.6.170.0270.06720.58
5.6.160.0070.08320.57
5.6.150.0000.09018.26
5.6.140.0100.03718.35
5.6.130.0070.08018.27
5.6.120.0030.05721.05
5.6.110.0070.06021.20
5.6.100.0130.07721.01
5.6.90.0100.09321.17
5.6.80.0130.07320.52
5.5.350.0470.06320.35
5.5.340.0000.05318.12
5.5.330.0000.04720.57
5.5.320.0430.07320.45
5.5.310.0230.06020.41
5.5.300.0130.06718.06
5.5.290.0030.05318.10
5.5.280.0070.08320.88
5.5.270.0100.08020.85
5.5.260.0070.08720.84
5.5.250.0030.05020.67
5.5.240.0030.07320.41
5.4.450.0470.07019.37
5.4.440.0400.03719.66
5.4.430.0230.04719.45
5.4.420.0370.04719.69
5.4.410.0300.03719.25
5.4.400.0370.03719.30
5.4.390.0330.03319.07
5.4.380.0330.03719.29
5.4.370.0300.04019.22
5.4.360.0270.04319.32
5.4.350.0430.04019.02
5.4.340.0200.04719.16
5.4.320.0300.03719.20
5.4.310.0330.03319.14
5.4.300.0370.03319.04
5.4.290.0330.03319.18
5.4.280.0370.05019.22
5.4.270.0400.05019.29
5.4.260.0230.04319.17
5.4.250.0430.06019.20
5.4.240.0330.05019.38
5.4.230.0400.03019.31
5.4.220.0430.04019.14
5.4.210.0330.03319.29
5.4.200.0330.03319.16
5.4.190.0330.03319.20
5.4.180.0330.03319.05
5.4.170.0270.05019.06
5.4.160.0270.04019.13
5.4.150.0370.05319.02
5.4.140.0330.03316.56
5.4.130.0400.06316.45
5.4.120.0270.03716.44
5.4.110.0300.03716.51
5.4.100.0270.03716.66
5.4.90.0400.04316.54
5.4.80.0400.04316.48
5.4.70.0300.04316.47
5.4.60.0400.06316.52
5.4.50.0430.06016.70
5.4.40.0300.07316.47
5.4.30.0300.04716.54
5.4.20.0470.05716.47
5.4.10.0370.04316.46
5.4.00.0470.05716.02
5.3.290.0330.08014.79
5.3.280.0330.03314.66
5.3.270.0400.04314.71
5.3.260.0430.06314.66
5.3.250.0230.05314.78
5.3.240.0370.03714.82
5.3.230.0330.03314.66
5.3.220.0330.03314.64
5.3.210.0300.03714.73
5.3.200.0400.06014.77
5.3.190.0400.06714.64
5.3.180.0430.06314.64
5.3.170.0430.06314.64
5.3.160.0230.05314.67
5.3.150.0270.04014.64
5.3.140.0400.06314.62
5.3.130.0470.06014.66
5.3.120.0300.03714.65
5.3.110.0300.07014.73
5.3.100.0430.06714.11
5.3.90.0430.06314.22
5.3.80.0370.03714.08
5.3.70.0300.05014.09
5.3.60.0430.06314.08
5.3.50.0300.04014.06
5.3.40.0370.06713.95
5.3.30.0270.04713.99
5.3.20.0370.05313.92
5.3.10.0330.04313.69
5.3.00.0330.03013.95
5.2.170.0230.02711.36
5.2.160.0170.05711.32
5.2.150.0270.03011.16
5.2.140.0270.04711.20
5.2.130.0270.04011.21
5.2.120.0200.03311.17
5.2.110.0430.04311.11
5.2.100.0430.04311.16
5.2.90.0270.03711.32
5.2.80.0270.03311.11
5.2.70.0400.03711.26
5.2.60.0230.03311.32
5.2.50.0300.05311.13
5.2.40.0270.02311.20
5.2.30.0230.04011.04
5.2.20.0270.05011.06
5.2.10.0230.03310.95
5.2.00.0270.03010.78
5.1.60.0330.04310.42
5.1.50.0200.02710.42
5.1.40.0130.03010.42
5.1.30.0300.03310.43
5.1.20.0200.04010.61
5.1.10.0200.02710.42
5.1.00.0230.04010.42
5.0.50.0200.03310.42
5.0.40.0200.01710.42
5.0.30.0170.06010.42
5.0.20.0170.03310.42
5.0.10.0100.03710.42
5.0.00.0170.05310.42
4.4.90.0130.02710.42
4.4.80.0170.03710.42
4.4.70.0100.02710.42
4.4.60.0230.03010.42
4.4.50.0130.01310.42
4.4.40.0100.02710.42
4.4.30.0130.03010.42
4.4.20.0130.02010.42
4.4.10.0130.01710.42
4.4.00.0130.02310.42
4.3.110.0100.02710.42
4.3.100.0170.01310.42
4.3.90.0100.02010.42
4.3.80.0130.04010.42
4.3.70.0100.02010.42
4.3.60.0100.01710.42
4.3.50.0100.02010.42
4.3.40.0130.02010.42
4.3.30.0030.02010.42
4.3.20.0070.02010.42
4.3.10.0070.02010.42
4.3.00.0070.01310.42

preferences:
40.35 ms | 401 KiB | 5 Q