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']; 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.00416.88
8.3.50.0100.00822.12
8.3.40.0140.00419.17
8.3.30.0090.00619.16
8.3.20.0040.00420.46
8.3.10.0060.00323.71
8.3.00.0060.00319.50
8.2.180.0120.00316.73
8.2.170.0140.00422.96
8.2.160.0070.00720.64
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0050.00326.16
8.2.120.0030.00522.38
8.2.110.0060.00321.29
8.2.100.0040.00718.16
8.2.90.0050.00318.28
8.2.80.0000.00817.97
8.2.70.0030.00617.86
8.2.60.0040.00418.29
8.2.50.0060.00618.07
8.2.40.0030.00618.53
8.2.30.0040.00418.26
8.2.20.0060.00318.00
8.2.10.0080.00020.18
8.2.00.0060.00317.87
8.1.280.0040.01125.92
8.1.270.0050.00322.34
8.1.260.0080.00026.35
8.1.250.0050.00228.09
8.1.240.0100.00022.39
8.1.230.0040.00721.07
8.1.220.0000.00817.91
8.1.210.0000.00820.09
8.1.200.0070.00317.60
8.1.190.0040.00417.68
8.1.180.0060.00318.10
8.1.170.0040.00418.78
8.1.160.0040.00422.25
8.1.150.0000.00718.70
8.1.140.0000.00717.56
8.1.130.0030.00317.94
8.1.120.0070.00017.67
8.1.110.0040.00417.76
8.1.100.0040.00417.54
8.1.90.0020.00517.55
8.1.80.0070.00017.64
8.1.70.0070.00017.63
8.1.60.0090.00017.76
8.1.50.0030.00517.65
8.1.40.0040.00417.82
8.1.30.0040.00417.82
8.1.20.0080.00017.91
8.1.10.0000.00717.84
8.1.00.0040.00417.59
8.0.300.0090.00020.21
8.0.290.0080.00017.00
8.0.280.0030.00518.55
8.0.270.0040.00417.38
8.0.260.0000.00717.04
8.0.250.0030.00317.15
8.0.240.0050.00317.14
8.0.230.0000.00817.14
8.0.220.0040.00417.21
8.0.210.0030.00317.09
8.0.200.0000.00617.32
8.0.190.0000.00917.18
8.0.180.0090.00017.16
8.0.170.0030.00517.11
8.0.160.0030.00617.10
8.0.150.0000.00717.23
8.0.140.0030.00417.10
8.0.130.0030.00313.57
8.0.120.0040.00417.17
8.0.110.0050.00317.09
8.0.100.0040.00416.97
8.0.90.0050.00317.21
8.0.80.0110.00817.00
8.0.70.0000.00817.06
8.0.60.0070.00017.06
8.0.50.0000.00817.11
8.0.30.0090.01117.31
8.0.20.0100.01117.40
8.0.10.0000.00717.13
8.0.00.0120.01017.12
7.4.330.0050.00015.23
7.4.320.0030.00316.65
7.4.300.0100.00016.81
7.4.290.0000.00716.62
7.4.280.0030.00316.67
7.4.270.0000.00816.66
7.4.260.0050.00216.71
7.4.250.0050.00316.67
7.4.240.0010.00616.72
7.4.230.0040.00416.89
7.4.220.0030.01616.76
7.4.210.0030.01316.73
7.4.200.0050.00316.92
7.4.190.0030.00316.66
7.4.160.0150.00716.52
7.4.150.0130.00617.40
7.4.140.0120.00617.86
7.4.130.0090.00816.78
7.4.120.0100.00916.74
7.4.110.0100.01316.91
7.4.100.0030.01416.85
7.4.90.0070.01116.84
7.4.80.0070.01419.39
7.4.70.0090.00916.71
7.4.60.0100.01016.83
7.4.50.0060.00316.64
7.4.40.0040.01422.77
7.4.30.0060.01816.78
7.4.00.0090.00315.46
7.3.330.0020.00213.63
7.3.320.0000.00513.58
7.3.310.0070.00016.66
7.3.300.0000.00716.70
7.3.290.0070.00716.66
7.3.280.0080.00816.63
7.3.270.0070.01117.40
7.3.260.0160.00416.71
7.3.250.0070.01116.77
7.3.240.0080.01516.84
7.3.230.0130.01016.70
7.3.210.0100.00616.55
7.3.200.0120.00619.39
7.3.190.0070.01016.93
7.3.180.0130.00316.62
7.3.170.0100.01316.86
7.3.160.0070.01016.82
7.3.120.0060.00915.11
7.3.10.0100.00316.58
7.3.00.0030.00716.61
7.2.330.0050.01217.00
7.2.320.0070.01117.02
7.2.310.0040.01316.62
7.2.300.0050.01516.86
7.2.290.0070.01016.98
7.2.130.0070.00716.62
7.2.120.0040.01116.68
7.2.110.0090.00916.52
7.2.100.0060.00916.53
7.2.90.0090.00616.79
7.2.80.0040.01116.66
7.2.70.0070.00416.72
7.2.60.0080.00816.53
7.2.50.0070.00316.90
7.2.40.0090.00416.72
7.2.30.0070.00716.91
7.2.20.0000.01116.47
7.2.10.0040.01016.69
7.2.00.0090.00617.97
7.1.250.0040.01115.48
7.1.100.0070.00718.44
7.1.70.0030.00717.32
7.1.60.0090.01219.33
7.1.50.0070.01117.18
7.1.00.0100.07022.57
7.0.200.0000.01016.76
7.0.140.0030.07322.09
7.0.60.0200.07720.12
7.0.50.0070.08017.99
7.0.40.0070.04320.19
7.0.30.0230.06720.30
7.0.20.0330.05020.26
7.0.10.0100.08320.16
7.0.00.0070.08020.31
5.6.280.0000.07720.98
5.6.210.0130.08020.59
5.6.200.0100.03718.36
5.6.190.0030.04320.42
5.6.180.0270.05720.75
5.6.170.0170.04320.57
5.6.160.0100.05320.57
5.6.150.0100.07718.36
5.6.140.0100.08018.31
5.6.130.0070.07718.24
5.6.120.0030.04021.05
5.6.110.0000.04321.17
5.6.100.0100.07321.09
5.6.90.0100.09321.04
5.6.80.0070.08320.57
5.6.70.4830.04320.43
5.5.350.0000.03320.45
5.5.340.0000.04318.16
5.5.330.0100.08020.57
5.5.320.0170.06320.48
5.5.310.0270.08320.58
5.5.300.0070.07318.16
5.5.290.0000.08718.05
5.5.280.0200.07321.03
5.5.270.0070.09020.93
5.5.260.0070.08720.93
5.5.250.0030.07320.84
5.5.240.0030.07720.29
5.4.450.1500.04019.39
5.4.440.0800.05719.46
5.4.430.0670.05719.62
5.4.420.0870.07019.57
5.4.410.0230.04019.50
5.4.400.0700.06019.33
5.4.390.0770.06019.30
5.4.380.0230.05318.60
5.4.370.0230.05318.92
5.4.360.0330.04318.84
5.4.350.0330.04718.87
5.4.340.0370.05018.92
5.4.320.0080.03512.67
5.4.310.0020.05012.66
5.4.300.0080.04012.67
5.4.290.0050.03912.67
5.4.280.0060.03612.57
5.4.270.0070.03412.57
5.4.260.0040.04712.57
5.4.250.0060.04812.57
5.4.240.0100.03212.57
5.4.230.0040.04112.56
5.4.220.0060.03612.55
5.4.210.0060.03612.56
5.4.200.0080.04212.56
5.4.190.0150.04312.55
5.4.180.0170.04212.55
5.4.170.0280.06312.56
5.4.160.0160.04412.55
5.4.150.0150.04512.55
5.4.140.0160.04212.23
5.4.130.0210.06912.22
5.4.120.0130.04412.18
5.4.110.0190.04012.18
5.4.100.0180.04012.18
5.4.90.0180.04112.18
5.4.80.0300.05912.18
5.4.70.0160.04512.17
5.4.60.0140.04612.18
5.4.50.0090.04812.17
5.4.40.0150.04212.15
5.4.30.0120.04912.16
5.4.20.0260.06112.15
5.4.10.0130.04512.15
5.4.00.0180.10011.64
5.3.290.0070.03812.94
5.3.280.0050.03812.86
5.3.270.0200.04212.86
5.3.260.0190.04212.86
5.3.250.0160.04412.86
5.3.240.0140.04712.86
5.3.230.0190.04612.85
5.3.220.0170.04312.82
5.3.210.0180.04412.82
5.3.200.0210.03812.82
5.3.190.0120.04912.82
5.3.180.0130.04612.81
5.3.170.0300.08912.82
5.3.160.0150.04712.82
5.3.150.0160.04712.82
5.3.140.0420.11012.81
5.3.130.0140.04712.80
5.3.120.0170.04712.80
5.3.110.0200.04212.80
5.3.100.0180.04512.29
5.3.90.0170.04312.27
5.3.80.0160.04612.26
5.3.70.0160.04412.26
5.3.60.0140.04612.24
5.3.50.0170.04512.20
5.3.40.0150.04512.19
5.3.30.0150.04412.16
5.3.20.0320.08711.93
5.3.10.0120.04311.90
5.3.00.0130.04211.89
5.2.170.0110.0359.39
5.2.160.0140.0329.39
5.2.150.0120.0349.39
5.2.140.0110.0359.38
5.2.130.0130.0339.35
5.2.120.0100.0369.35
5.2.110.0120.0359.35
5.2.100.0130.0329.35
5.2.90.0100.0369.35
5.2.80.0290.0489.34
5.2.70.0160.0309.34
5.2.60.0140.0329.29
5.2.50.0130.0339.26
5.2.40.0070.0409.24
5.2.30.0170.0319.22
5.2.20.0130.0349.20
5.2.10.0240.0829.11
5.2.00.0090.0358.97
5.1.60.0090.0308.26
5.1.50.0090.0318.26
5.1.40.0110.0288.24
5.1.30.0100.0328.59
5.1.20.0110.0318.60
5.1.10.0090.0328.18
5.1.00.0070.0338.18
5.0.50.0080.0256.66
5.0.40.0090.0226.52
5.0.30.0090.0356.33
5.0.20.0100.0216.30
5.0.10.0100.0216.28
5.0.00.0080.0356.27
4.4.90.0060.0184.78
4.4.80.0050.0194.75
4.4.70.0080.0174.75
4.4.60.0030.0224.75
4.4.50.0060.0184.77
4.4.40.0020.0334.71
4.4.30.0110.0144.76
4.4.20.0090.0164.85
4.4.10.0080.0174.85
4.4.00.0060.0304.76
4.3.110.0170.0404.67
4.3.100.0070.0174.66
4.3.90.0090.0164.63
4.3.80.0030.0314.58
4.3.70.0050.0184.63
4.3.60.0050.0194.62
4.3.50.0050.0194.63
4.3.40.0040.0294.54
4.3.30.0070.0163.30
4.3.20.0040.0193.28
4.3.10.0050.0173.24
4.3.00.0230.01315.59

preferences:
44.63 ms | 401 KiB | 5 Q