3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test extends ArrayIterator { public function __toString() { 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->offsetGet($offset)); } public function offsetGet($offset) { if ($this->xml->getName() == $offset) { return $this; } return new Test((array)$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']; echo $xml['note']['recursive']['val'][0]; var_dump($xml->getIterator());

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.0070.00717.00
8.3.50.0080.01022.13
8.3.40.0100.00618.76
8.3.30.0110.00319.29
8.3.20.0040.00420.59
8.3.10.0110.00723.82
8.3.00.0080.00417.75
8.2.180.0120.00916.60
8.2.170.0160.00622.96
8.2.160.0070.00720.68
8.2.150.0030.00624.18
8.2.140.0090.00024.66
8.2.130.0000.00826.16
8.2.120.0140.00322.45
8.2.110.0070.00322.22
8.2.100.0040.00817.98
8.2.90.0030.00619.38
8.2.80.0000.00818.18
8.2.70.0030.00617.63
8.2.60.0000.00818.05
8.2.50.0000.00818.07
8.2.40.0050.00318.33
8.2.30.0080.00018.24
8.2.20.0050.00317.95
8.2.10.0040.00417.86
8.2.00.0040.00417.96
8.1.280.0090.00925.92
8.1.270.0030.00624.17
8.1.260.0060.00326.35
8.1.250.0030.00628.09
8.1.240.0030.00623.91
8.1.230.0040.00819.41
8.1.220.0050.00317.77
8.1.210.0050.00318.77
8.1.200.0030.00617.60
8.1.190.0000.00817.76
8.1.180.0030.00618.10
8.1.170.0050.00318.90
8.1.160.0070.00422.30
8.1.150.0000.00818.82
8.1.140.0040.00417.72
8.1.130.0040.00417.69
8.1.120.0070.00017.63
8.1.110.0050.00517.68
8.1.100.0030.00517.66
8.1.90.0000.00717.54
8.1.80.0070.00017.70
8.1.70.0000.00717.64
8.1.60.0070.00417.79
8.1.50.0060.00317.65
8.1.40.0030.00617.77
8.1.30.0060.00317.82
8.1.20.0000.00817.80
8.1.10.0000.00817.74
8.1.00.0030.00617.70
8.0.300.0040.00418.77
8.0.290.0050.00317.41
8.0.280.0070.00018.57
8.0.270.0080.00017.48
8.0.260.0070.00016.98
8.0.250.0030.00317.12
8.0.240.0040.00317.06
8.0.230.0000.00817.10
8.0.220.0000.00717.07
8.0.210.0000.00717.16
8.0.200.0060.00017.16
8.0.190.0000.00717.15
8.0.180.0050.00217.08
8.0.170.0040.00417.23
8.0.160.0070.00017.18
8.0.150.0000.00716.99
8.0.140.0040.00417.02
8.0.130.0090.00013.52
8.0.120.0050.00317.03
8.0.110.0040.00417.00
8.0.100.0000.00816.94
8.0.90.0000.00717.13
8.0.80.0180.00017.18
8.0.70.0080.00017.02
8.0.60.0080.00017.00
8.0.50.0040.00417.01
8.0.30.0080.01117.37
8.0.20.0090.01117.59
8.0.10.0050.00317.13
8.0.00.0060.01416.78
7.4.330.0030.00315.29
7.4.320.0050.00216.84
7.4.300.0020.00516.79
7.4.290.0030.00316.66
7.4.280.0030.00316.73
7.4.270.0000.00716.81
7.4.260.0050.00316.75
7.4.250.0040.00416.65
7.4.240.0000.00716.85
7.4.230.0040.00416.76
7.4.220.0060.01216.82
7.4.210.0040.01116.85
7.4.200.0040.00416.76
7.4.190.0070.00016.73
7.4.160.0130.00316.68
7.4.150.0110.00817.40
7.4.140.0100.00817.86
7.4.130.0110.00816.61
7.4.120.0080.00916.82
7.4.110.0060.01316.58
7.4.100.0130.01016.88
7.4.90.0140.00416.79
7.4.80.0100.00719.39
7.4.70.0080.01016.66
7.4.60.0070.01016.69
7.4.50.0000.00516.53
7.4.40.0060.00622.77
7.4.30.0120.00316.81
7.4.00.0100.00714.94
7.3.330.0030.00313.54
7.3.320.0000.00513.30
7.3.310.0060.00016.39
7.3.300.0030.00316.62
7.3.290.0090.00616.63
7.3.280.0040.01416.57
7.3.270.0130.00517.40
7.3.260.0030.01516.80
7.3.250.0120.00816.80
7.3.240.0030.01916.75
7.3.230.0110.00816.82
7.3.210.0140.00416.85
7.3.200.0130.00819.39
7.3.190.0150.00416.64
7.3.180.0100.01016.50
7.3.170.0060.00916.79
7.3.160.0100.00716.59
7.3.120.0030.01414.98
7.2.330.0090.00917.08
7.2.320.0040.01516.68
7.2.310.0090.00916.96
7.2.300.0030.01317.09
7.2.290.0120.01216.64
7.2.60.0030.00917.01
7.2.00.0060.00619.61
7.1.200.0070.00715.90
7.1.100.0030.00918.35
7.1.70.0030.01317.42
7.1.60.0130.01319.31
7.1.50.0070.01016.92
7.1.00.0070.07322.52
7.0.200.0030.00517.05
7.0.140.0030.07322.18
7.0.60.0130.06720.18
7.0.50.0070.08017.93
7.0.40.0130.07720.41
7.0.30.0300.06020.30
7.0.20.0130.04720.28
7.0.10.0170.04720.40
7.0.00.0200.06720.21
5.6.280.0000.07721.05
5.6.210.0070.08720.94
5.6.200.0070.07018.36
5.6.190.0030.05020.41
5.6.180.0030.07720.55
5.6.170.0330.04020.69
5.6.160.0000.04720.64
5.6.150.0030.08018.23
5.6.140.0070.05718.23
5.6.130.0070.03718.25
5.6.120.0030.08721.20
5.6.110.0000.07721.19
5.6.100.0100.09021.19
5.6.90.0030.08021.20
5.6.80.0030.07020.44
5.6.70.0400.06720.50
5.5.350.0000.08720.61
5.5.340.0170.07718.16
5.5.330.0170.07720.37
5.5.320.0000.04720.34
5.5.310.0330.07720.58
5.5.300.0030.08018.05
5.5.290.0070.04318.03
5.5.280.0030.04020.94
5.5.270.0100.08720.78
5.5.260.0100.07720.79
5.5.250.0070.07320.84
5.5.240.0030.08720.49
5.4.450.0770.04719.50
5.4.440.0670.06319.59
5.4.430.0730.06719.63
5.4.420.0670.06719.28
5.4.410.0670.06319.38
5.4.400.0470.06319.21
5.4.390.0700.05319.30
5.4.380.0230.06318.83
5.4.370.0230.04718.78
5.4.360.0200.07718.63
5.4.350.0130.06318.73
5.4.340.0230.07318.82
5.4.320.0110.03612.67
5.4.310.0120.05312.67
5.4.300.0090.03412.67
5.4.290.0060.03812.66
5.4.280.0050.03712.56
5.4.270.0060.04412.57
5.4.260.0070.03612.56
5.4.250.0110.04112.56
5.4.240.0100.04212.56
5.4.230.0110.03912.55
5.4.220.0070.04012.56
5.4.210.0110.03812.55
5.4.200.0080.03912.56
5.4.190.0110.04612.54
5.4.180.0130.04612.54
5.4.170.0190.03812.55
5.4.160.0170.04212.55
5.4.150.0140.04512.55
5.4.140.0160.04412.23
5.4.130.0190.04112.22
5.4.120.0150.05312.17
5.4.110.0200.04812.18
5.4.100.0360.08212.18
5.4.90.0170.04012.17
5.4.80.0130.04312.18
5.4.70.0180.03912.16
5.4.60.0170.03912.17
5.4.50.0170.03912.17
5.4.40.0110.04512.16
5.4.30.0170.04212.16
5.4.20.0170.04112.16
5.4.10.0140.04612.16
5.4.00.0120.04611.64
5.3.290.0100.03612.93
5.3.280.0080.03712.86
5.3.270.0190.04412.86
5.3.260.0110.04912.86
5.3.250.0180.04212.86
5.3.240.0160.04512.86
5.3.230.0270.06412.85
5.3.220.0180.04112.82
5.3.210.0190.04112.82
5.3.200.0190.04212.82
5.3.190.0160.04512.82
5.3.180.0130.04612.82
5.3.170.0220.06712.82
5.3.160.0200.04012.82
5.3.150.0120.04712.82
5.3.140.0180.04112.81
5.3.130.0220.07012.80
5.3.120.0180.04312.80
5.3.110.0120.04812.80
5.3.100.0260.09512.29
5.3.90.0180.04012.27
5.3.80.0140.04612.26
5.3.70.0170.04212.26
5.3.60.0160.04312.24
5.3.50.0210.04012.19
5.3.40.0190.04112.19
5.3.30.0200.04012.15
5.3.20.0190.04011.93
5.3.10.0150.04211.90
5.3.00.0110.04511.89
5.2.170.0130.0349.38
5.2.160.0130.0349.38
5.2.150.0100.0379.38
5.2.140.0130.0349.38
5.2.130.0170.0299.34
5.2.120.0140.0359.34
5.2.110.0140.0349.34
5.2.100.0330.0449.34
5.2.90.0130.0339.34
5.2.80.0100.0399.33
5.2.70.0150.0319.33
5.2.60.0120.0349.29
5.2.50.0100.0369.26
5.2.40.0130.0339.23
5.2.30.0120.0339.21
5.2.20.0140.0329.20
5.2.10.0120.0359.11
5.2.00.0110.0368.96
5.1.60.0130.0288.25
5.1.50.0110.0298.25
5.1.40.0220.0518.24
5.1.30.0100.0328.59
5.1.20.0080.0348.60
5.1.10.0140.0288.17
5.1.00.0120.0308.17
5.0.50.0060.0276.66
5.0.40.0090.0236.52
5.0.30.0070.0376.32
5.0.20.0070.0246.30
5.0.10.0090.0226.28
5.0.00.0100.0336.27
4.4.90.0070.0174.78
4.4.80.0060.0184.76
4.4.70.0100.0154.75
4.4.60.0090.0174.75
4.4.50.0080.0174.77
4.4.40.0070.0284.71
4.4.30.0170.0384.76
4.4.20.0040.0204.84
4.4.10.0050.0194.85
4.4.00.0070.0294.76
4.3.110.0080.0164.67
4.3.100.0070.0174.66
4.3.90.0090.0154.64
4.3.80.0060.0284.58
4.3.70.0090.0154.63
4.3.60.0060.0174.63
4.3.50.0080.0174.63
4.3.40.0060.0284.54
4.3.30.0040.0193.30
4.3.20.0020.0213.27
4.3.10.0050.0183.24
4.3.00.0030.04315.59

preferences:
46.62 ms | 401 KiB | 5 Q