3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test extends ArrayIterator { public function __toString() { if (count($this) > 1) { return (string) $this->xml[0]; } return (string) $this->xml; } } 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.60.0100.01018.68
8.3.50.0170.00522.11
8.3.40.0080.00819.11
8.3.30.0120.00619.37
8.3.20.0040.00420.50
8.3.10.0050.00322.09
8.3.00.0060.00322.53
8.2.180.0100.00716.86
8.2.170.0080.00822.96
8.2.160.0090.00621.02
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0100.01026.16
8.2.120.0050.00319.48
8.2.110.0060.00322.27
8.2.100.0090.00319.41
8.2.90.0030.00518.00
8.2.80.0040.00418.18
8.2.70.0000.00817.88
8.2.60.0000.00918.29
8.2.50.0080.00018.07
8.2.40.0080.00018.47
8.2.30.0030.00618.27
8.2.20.0000.00817.83
8.2.10.0090.00019.63
8.2.00.0000.00718.01
8.1.280.0060.00925.92
8.1.270.0000.00822.44
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.01422.73
8.1.230.0110.00019.24
8.1.220.0000.00818.04
8.1.210.0030.00518.77
8.1.200.0060.00317.50
8.1.190.0090.00017.77
8.1.180.0040.00418.95
8.1.170.0030.00518.81
8.1.160.0030.00622.20
8.1.150.0040.00418.80
8.1.140.0020.00517.70
8.1.130.0070.00018.00
8.1.120.0050.00317.67
8.1.110.0000.00817.57
8.1.100.0040.00417.59
8.1.90.0000.00717.64
8.1.80.0000.00717.67
8.1.70.0000.00717.64
8.1.60.0040.00417.71
8.1.50.0000.00817.63
8.1.40.0000.00817.72
8.1.30.0000.00817.84
8.1.20.0030.00517.88
8.1.10.0050.00317.68
8.1.00.0030.00517.75
8.0.300.0070.00019.95
8.0.290.0000.00817.28
8.0.280.0040.00418.66
8.0.270.0000.00817.40
8.0.260.0000.00817.09
8.0.250.0030.00317.13
8.0.240.0000.00717.06
8.0.230.0000.00717.13
8.0.220.0030.00317.15
8.0.210.0070.00017.03
8.0.200.0070.00017.18
8.0.190.0100.00017.09
8.0.180.0000.00817.14
8.0.170.0050.00517.14
8.0.160.0000.00717.16
8.0.150.0030.00517.20
8.0.140.0040.00417.08
8.0.130.0050.00013.48
8.0.120.0040.00417.15
8.0.110.0070.00016.98
8.0.100.0040.00416.95
8.0.90.0040.00416.99
8.0.80.0150.00317.18
8.0.70.0000.00817.03
8.0.60.0000.00816.97
8.0.50.0040.00416.92
8.0.30.0130.00717.21
8.0.20.0150.00717.40
8.0.10.0000.00717.11
8.0.00.0090.01117.08
7.4.330.0000.00515.00
7.4.320.0030.00316.68
7.4.300.0060.00016.77
7.4.290.0080.00016.75
7.4.280.0030.00316.74
7.4.270.0030.00316.72
7.4.260.0000.00716.77
7.4.250.0080.00016.73
7.4.240.0020.00616.73
7.4.230.0000.00816.75
7.4.220.0060.01516.68
7.4.210.0130.00416.87
7.4.200.0000.00716.66
7.4.190.0000.00716.51
7.4.160.0130.00316.74
7.4.150.0090.00917.40
7.4.140.0090.01617.86
7.4.130.0020.01516.78
7.4.120.0090.00916.66
7.4.110.0030.01416.77
7.4.100.0120.00816.51
7.4.90.0100.01416.81
7.4.80.0140.01019.39
7.4.70.0060.01016.62
7.4.60.0090.00916.80
7.4.50.0000.00516.39
7.4.40.0080.00422.77
7.4.30.0160.00616.78
7.4.00.0100.00315.06
7.3.330.0050.00013.51
7.3.320.0030.00313.38
7.3.310.0070.00016.60
7.3.300.0070.00016.51
7.3.290.0100.00516.60
7.3.280.0020.01316.60
7.3.270.0130.00317.40
7.3.260.0130.00316.63
7.3.250.0100.00816.65
7.3.240.0110.00516.63
7.3.230.0060.01216.78
7.3.210.0090.00916.64
7.3.200.0110.00719.39
7.3.190.0110.01316.71
7.3.180.0090.00616.52
7.3.170.0060.01016.75
7.3.160.0130.00316.61
7.3.120.0070.00315.24
7.2.330.0090.01216.99
7.2.320.0070.01016.94
7.2.310.0000.01816.76
7.2.300.0030.01516.91
7.2.290.0090.00916.82
7.2.00.0030.00619.32
7.1.200.0080.00515.81
7.1.100.0060.00918.04
7.1.70.0060.01017.16
7.1.60.0040.01919.82
7.1.50.0110.01417.12
7.1.00.0100.06022.61
7.0.200.0030.00716.65
7.0.140.0030.07722.21
7.0.60.0000.07719.98
7.0.50.0100.07717.99
7.0.40.0070.07020.48
7.0.30.0300.07720.31
7.0.20.0170.04320.30
7.0.10.0030.04320.26
7.0.00.0070.09020.29
5.6.280.0070.06721.15
5.6.210.0200.06020.54
5.6.200.0130.04018.31
5.6.190.0030.09020.78
5.6.180.0230.05720.55
5.6.170.0230.06020.69
5.6.160.0000.04320.55
5.6.150.0100.07718.36
5.6.140.0100.06318.19
5.6.130.0100.04718.30
5.6.120.0000.09021.06
5.6.110.0070.08021.22
5.6.100.0170.08021.14
5.6.90.0070.08321.05
5.6.80.0130.06320.41
5.5.350.0300.07320.55
5.5.340.0100.05318.12
5.5.330.0130.05720.62
5.5.320.0070.03720.45
5.5.310.0270.07020.33
5.5.300.0030.07718.13
5.5.290.0170.07318.15
5.5.280.0000.06721.04
5.5.270.0000.04320.85
5.5.260.0100.08321.10
5.5.250.0030.09020.68
5.5.240.0070.07320.14
5.4.450.0230.06719.39
5.4.440.0200.05719.40
5.4.430.0130.05319.38
5.4.420.0170.08319.34
5.4.410.0270.05719.25
5.4.400.0200.04719.37
5.4.390.0270.05719.23
5.4.380.0370.06019.07
5.4.370.0200.08019.29
5.4.360.0200.07019.33
5.4.350.0230.07319.23
5.4.340.0230.04719.14
5.4.320.0330.04019.15
5.4.310.0270.06019.12
5.4.300.0170.08319.13
5.4.290.0270.07019.07
5.4.280.0170.07719.14
5.4.270.0300.06719.05
5.4.260.0270.05319.29
5.4.250.0300.06319.16
5.4.240.0230.07319.24
5.4.230.0330.06319.08
5.4.220.0300.06719.15
5.4.210.0200.04719.15
5.4.200.0230.07019.35
5.4.190.0100.04719.23
5.4.180.0130.05719.14
5.4.170.0270.07019.31
5.4.160.0200.07319.05
5.4.150.0300.07019.29
5.4.140.0300.06316.66
5.4.130.0230.06716.61
5.4.120.0170.08016.45
5.4.110.0270.06716.58
5.4.100.0200.07316.71
5.4.90.0230.05316.68
5.4.80.0200.06016.51
5.4.70.0270.06716.68
5.4.60.0170.05716.68
5.4.50.0230.06716.46
5.4.40.0170.07316.55
5.4.30.0170.04316.67
5.4.20.0200.06716.65
5.4.10.0200.04716.35
5.4.00.0230.05716.08
5.3.290.0200.05714.77
5.3.280.0130.04714.86
5.3.270.0270.06714.84
5.3.260.0330.06714.88
5.3.250.0230.05014.67
5.3.240.0330.04714.70
5.3.230.0230.06714.81
5.3.220.0130.05314.64
5.3.210.0200.07714.75
5.3.200.0230.08014.77
5.3.190.0300.06314.64
5.3.180.0570.02014.63
5.3.170.0300.07014.67
5.3.160.0230.06714.64
5.3.150.0230.04014.89
5.3.140.0230.07314.63
5.3.130.0230.04314.82
5.3.120.0230.04014.63
5.3.110.0170.04714.64
5.3.100.0300.03714.13
5.3.90.0230.06314.29
5.3.80.0300.04314.20
5.3.70.0170.05014.20
5.3.60.0170.07314.09
5.3.50.0230.06314.02
5.3.40.0200.06314.06
5.3.30.0230.03314.19
5.3.20.0300.07013.79
5.3.10.0200.05313.88
5.3.00.0300.06313.65
5.2.170.0170.06312.23
5.2.160.0200.05712.23
5.2.150.0170.03712.23
5.2.140.0200.06312.23
5.2.130.0200.06012.23
5.2.120.0200.05012.23
5.2.110.0200.05712.23
5.2.100.0170.06012.23
5.2.90.0170.05712.23
5.2.80.0200.03712.23
5.2.70.0270.05312.23
5.2.60.0170.06312.23
5.2.50.0130.06012.23
5.2.40.0230.03312.23
5.2.30.0100.05312.23
5.2.20.0130.04012.23
5.2.10.0130.05012.23
5.2.00.0170.05712.23
5.1.60.0270.03312.23
5.1.50.0200.04012.23
5.1.40.0330.02712.23
5.1.30.0200.05012.23
5.1.20.0170.05312.23
5.1.10.0170.04712.23
5.1.00.0200.04312.23
5.0.50.0170.03012.23
5.0.40.0070.04312.23
5.0.30.0070.06012.23
5.0.20.0030.03712.23
5.0.10.0130.03312.23
5.0.00.0100.05012.23
4.4.90.0100.02012.23
4.4.80.0100.02712.23
4.4.70.0070.02712.23
4.4.60.0130.02712.23
4.4.50.0070.03712.23
4.4.40.0130.05712.23
4.4.30.0100.03312.23
4.4.20.0070.03012.23
4.4.10.0070.03712.23
4.4.00.0070.05712.23
4.3.110.0100.03012.23
4.3.100.0100.02712.23
4.3.90.0100.02012.23
4.3.80.0070.05312.23
4.3.70.0070.03312.23
4.3.60.0170.01712.23
4.3.50.0100.03312.23
4.3.40.0100.04312.23
4.3.30.0000.02312.23
4.3.20.0030.02712.23
4.3.10.0030.04012.23
4.3.00.0030.02012.23

preferences:
55.27 ms | 401 KiB | 5 Q