3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test extends ArrayIterator { public function __toString() { /*if (count($this) > 1) { return (string) $this[0]; }*/ return (string) $this[0]; } } 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 new Test((array)$this->xml->$offset); } 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'][0]; 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.70.0060.01218.93
8.3.60.0080.00818.80
8.3.50.0100.01222.13
8.3.40.0040.01119.18
8.3.30.0110.00419.29
8.3.20.0040.00420.48
8.3.10.0050.00323.60
8.3.00.0080.00021.02
8.2.180.0130.00617.00
8.2.170.0150.00722.96
8.2.160.0150.00620.72
8.2.150.0070.00024.18
8.2.140.0020.00524.66
8.2.130.0000.02026.16
8.2.120.0040.00420.80
8.2.110.0030.00619.46
8.2.100.0090.00618.09
8.2.90.0080.00018.28
8.2.80.0090.00317.97
8.2.70.0040.00418.18
8.2.60.0030.00518.18
8.2.50.0000.00818.10
8.2.40.0000.00820.80
8.2.30.0070.00018.43
8.2.20.0040.00417.81
8.2.10.0020.00518.25
8.2.00.0040.00418.15
8.1.280.0140.00725.92
8.1.270.0060.00324.09
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00720.71
8.1.230.0040.00821.20
8.1.220.0030.00617.74
8.1.210.0080.00019.16
8.1.200.0080.00017.48
8.1.190.0040.00419.18
8.1.180.0040.00418.10
8.1.170.0040.00418.74
8.1.160.0000.00822.13
8.1.150.0080.00018.85
8.1.140.0000.00717.56
8.1.130.0030.00317.96
8.1.120.0000.00717.77
8.1.110.0040.00417.63
8.1.100.0050.00217.65
8.1.90.0000.00817.69
8.1.80.0030.00417.63
8.1.70.0040.00417.59
8.1.60.0030.00717.76
8.1.50.0000.00917.83
8.1.40.0000.00917.71
8.1.30.0060.00317.91
8.1.20.0020.00517.84
8.1.10.0030.00617.70
8.1.00.0030.00617.80
8.0.300.0040.00420.02
8.0.290.0040.00416.88
8.0.280.0030.00318.71
8.0.270.0040.00417.54
8.0.260.0000.00717.38
8.0.250.0000.00717.14
8.0.240.0000.00717.13
8.0.230.0000.00817.11
8.0.220.0000.00717.07
8.0.210.0040.00417.07
8.0.200.0000.00717.12
8.0.190.0040.00417.08
8.0.180.0060.00317.11
8.0.170.0000.00817.17
8.0.160.0040.00416.93
8.0.150.0000.00717.07
8.0.140.0030.00517.12
8.0.130.0080.00013.50
8.0.120.0030.00517.11
8.0.110.0000.00717.13
8.0.100.0040.00417.12
8.0.90.0000.00816.96
8.0.80.0060.01017.18
8.0.70.0030.00516.97
8.0.60.0070.00017.07
8.0.50.0000.00717.13
8.0.30.0090.00917.37
8.0.20.0120.00917.40
8.0.10.0000.00817.06
8.0.00.0070.01017.13
7.4.330.0000.00615.33
7.4.320.0070.00016.66
7.4.300.0030.00316.86
7.4.290.0040.00416.66
7.4.280.0040.00416.70
7.4.270.0040.00416.69
7.4.260.0000.00816.81
7.4.250.0030.00616.84
7.4.240.0010.00616.80
7.4.230.0050.00316.71
7.4.220.0100.00716.94
7.4.210.0060.00916.84
7.4.200.0000.00716.86
7.4.160.0060.01116.53
7.4.150.0060.01217.40
7.4.140.0040.01417.86
7.4.130.0120.00816.78
7.4.120.0130.00416.81
7.4.110.0140.01016.66
7.4.100.0060.01216.83
7.4.90.0070.01016.61
7.4.80.0070.01019.39
7.4.70.0070.01016.70
7.4.60.0130.00416.72
7.4.50.0000.00616.82
7.4.40.0090.00616.82
7.4.30.0100.00716.71
7.4.00.0150.00015.41
7.3.330.0000.00513.40
7.3.320.0000.00613.59
7.3.310.0070.00016.68
7.3.300.0080.00016.50
7.3.290.0060.00816.59
7.3.280.0100.00816.58
7.3.270.0040.01417.40
7.3.260.0030.01416.79
7.3.250.0080.01016.70
7.3.240.0070.01016.79
7.3.230.0070.01016.74
7.3.210.0060.01316.54
7.3.200.0090.01219.39
7.3.190.0060.01616.64
7.3.180.0070.01016.83
7.3.170.0060.00916.75
7.3.160.0100.00616.85
7.3.120.0030.01014.75
7.2.330.0160.00317.00
7.2.320.0110.00816.91
7.2.310.0140.00716.89
7.2.300.0080.00816.98
7.2.290.0090.00916.80
7.1.70.0110.00617.28
7.1.60.0100.01619.70
7.1.50.0260.01034.97
7.1.00.0000.08022.49
7.0.200.0040.00716.90
7.0.140.0070.06722.11
7.0.100.0300.08020.23
7.0.90.0330.04320.17
7.0.80.0230.04720.20
7.0.70.0300.07720.02
7.0.60.0400.06320.04
7.0.50.0200.04320.42
7.0.40.0000.08720.28
7.0.30.0130.08020.21
7.0.20.0170.07320.23
7.0.10.0130.07320.05
7.0.00.0070.08720.12
5.6.250.0100.07020.72
5.6.240.0070.08320.73
5.6.230.0000.08320.65
5.6.220.0100.04020.79
5.6.210.0100.07320.68
5.6.200.0130.04021.21
5.6.190.0070.08321.30
5.6.180.0030.05321.20
5.6.170.0130.07321.08
5.6.160.0030.08721.11
5.6.150.0130.08021.13
5.6.140.0100.04721.10
5.6.130.0100.08321.17
5.6.120.0030.08321.03
5.6.110.0100.07721.09
5.6.100.0000.04721.13
5.6.90.0030.08721.14
5.6.80.0030.07720.50
5.6.70.0030.07320.43
5.6.60.0030.08720.57
5.6.50.0030.05320.43
5.6.40.0130.07720.63
5.6.30.0170.07020.61
5.6.20.0170.06720.63
5.6.10.0130.07320.46
5.6.00.0130.07720.59
5.5.380.0170.06720.48
5.5.370.0100.07020.57
5.5.360.0170.04020.48
5.5.350.0100.07320.50
5.5.340.0100.07320.96
5.5.330.0070.08020.91
5.5.320.0070.08320.87
5.5.310.0130.08021.05
5.5.300.0100.07721.07
5.5.290.0030.08320.87
5.5.280.0100.07020.86
5.5.270.0070.08021.01
5.5.260.0100.06721.06
5.5.250.0030.08720.68
5.5.240.0100.08020.42
5.5.230.0070.05020.45
5.5.220.0030.05320.38
5.5.210.0100.07320.21
5.5.200.0130.07020.41
5.5.190.0100.06720.28
5.5.180.0070.08020.24
5.5.160.0130.07320.38
5.5.150.0100.06720.37
5.5.140.0100.07720.30
5.5.130.0030.08020.18
5.5.120.0030.08020.41
5.5.110.0130.07020.40
5.5.100.0070.08320.27
5.5.90.0030.06320.29
5.5.80.0100.05720.27
5.5.70.0030.05720.26
5.5.60.0130.06720.25
5.5.50.0100.06320.20
5.5.40.0070.07720.13
5.5.30.0070.08020.26
5.5.20.0100.07320.27
5.5.10.0100.06020.12
5.5.00.0100.06720.10
5.4.450.0030.05319.45
5.4.440.0170.07019.57
5.4.430.0000.05719.58
5.4.420.0100.06319.58
5.4.410.0100.06019.43
5.4.400.0070.04319.12
5.4.390.0200.06319.23
5.4.380.0030.05318.95
5.4.370.0130.07018.94
5.4.360.0030.08319.28
5.4.350.0100.06719.11
5.4.340.0000.07019.23
5.4.320.0100.07019.23
5.4.310.0170.06019.23
5.4.300.0130.07019.28
5.4.290.0200.06319.26
5.4.280.0100.04719.10
5.4.270.0170.06319.36
5.4.260.0070.08019.02
5.4.250.0030.04319.25
5.4.240.0100.07019.27
5.4.230.0030.08019.20
5.4.220.0070.08019.23
5.4.210.0070.07718.93
5.4.200.0000.07719.24
5.4.190.0100.04019.23
5.4.180.0070.03319.26
5.4.170.0030.07719.23
5.4.160.0300.05719.21
5.4.150.0070.05319.02
5.4.140.0100.07316.55
5.4.130.0130.06316.47
5.4.120.0070.04016.52
5.4.110.0030.07316.69
5.4.100.0100.06716.57
5.4.90.0100.06716.60
5.4.80.0100.06016.62
5.4.70.0030.05016.57
5.4.60.0030.07716.48
5.4.50.0070.07016.53
5.4.40.0100.06716.61
5.4.30.0130.07016.44
5.4.20.0100.06316.46
5.4.10.0130.06716.61
5.4.00.0070.07715.98
5.3.290.0170.06314.94
5.3.280.0070.07714.88
5.3.270.0030.04014.66
5.3.260.0100.07314.66
5.3.250.0070.08014.70
5.3.240.0070.07714.80
5.3.230.0030.07714.79
5.3.220.0070.07714.73
5.3.210.0030.05714.66
5.3.200.0030.07314.64
5.3.190.0070.04714.84
5.3.180.0130.04014.73
5.3.170.0030.07314.85
5.3.160.0130.07314.72
5.3.150.0100.05714.61
5.3.140.0070.07014.65
5.3.130.0070.07714.64
5.3.120.0030.07014.84
5.3.110.0030.08014.79
5.3.100.0100.07014.20
5.3.90.0100.05314.28
5.3.80.0070.07314.11
5.3.70.0170.06014.18
5.3.60.0100.07313.99
5.3.50.0070.05714.18
5.3.40.0100.06713.94
5.3.30.0030.07014.02
5.3.20.0070.07313.93
5.3.10.0100.06713.75
5.3.00.0030.03713.73
5.2.170.0070.05011.28
5.2.160.0100.05311.41
5.2.150.0030.03711.38
5.2.140.0100.05711.38
5.2.130.0070.05711.12
5.2.120.0070.04311.29
5.2.110.0100.05711.37
5.2.100.0030.05711.29
5.2.90.0070.06011.35
5.2.80.0000.05311.36
5.2.70.0070.05011.37
5.2.60.0030.06011.13
5.2.50.0030.05311.27
5.2.40.0030.06311.02
5.2.30.0030.03711.21
5.2.20.0030.03011.23
5.2.10.0030.04310.91
5.2.00.0000.05310.91
5.1.60.0000.05010.14
5.1.50.0070.02710.16
5.1.40.0030.05310.09
5.1.30.0070.03310.57
5.1.20.0070.02310.41
5.1.10.0070.03310.18
5.1.00.0070.02710.09
5.0.50.0070.0438.91
5.0.40.0000.0378.91
5.0.30.0030.0538.91
5.0.20.0000.0438.91
5.0.10.0030.0438.91
5.0.00.0030.0338.91
4.4.90.0030.0178.91
4.4.80.0000.0238.91
4.4.70.0000.0408.91
4.4.60.0030.0178.91
4.4.50.0000.0378.91
4.4.40.0070.0278.91
4.4.30.0100.0308.91
4.4.20.0070.0308.91
4.4.10.0030.0178.91
4.4.00.0000.0408.91
4.3.110.0070.0208.91
4.3.100.0070.0308.91
4.3.90.0000.0408.91
4.3.80.0030.0508.91
4.3.70.0000.0208.91
4.3.60.0000.0378.91
4.3.50.0070.0308.91
4.3.40.0030.0538.91
4.3.30.0000.0378.91
4.3.20.0030.0208.91
4.3.10.0000.0408.91
4.3.00.0000.0378.91

preferences:
40.89 ms | 401 KiB | 5 Q