3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $current; 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; } $this->current = $this->xml->$offset; return new self($this->xml->$offset->asXML(), false); } public function __toString() { return $this->current; } 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']; //var_dump((string)$xml['note']['recursive']);

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.01418.68
8.3.50.0130.00821.39
8.3.40.0180.00019.21
8.3.30.0140.00019.14
8.3.20.0050.00319.02
8.3.10.0040.00421.32
8.3.00.0040.00422.15
8.2.180.0090.00616.99
8.2.170.0120.00422.96
8.2.160.0100.00320.73
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0070.00021.30
8.2.110.0100.00019.52
8.2.100.0110.00018.07
8.2.90.0000.00819.47
8.2.80.0080.00018.30
8.2.70.0090.00317.88
8.2.60.0040.00418.18
8.2.50.0040.00418.07
8.2.40.0050.00318.16
8.2.30.0040.00421.54
8.2.20.0000.00817.97
8.2.10.0000.00818.17
8.2.00.0060.00318.00
8.1.280.0070.01525.92
8.1.270.0040.00423.99
8.1.260.0090.00626.35
8.1.250.0040.00428.09
8.1.240.0000.00921.16
8.1.230.0110.00021.35
8.1.220.0040.00418.77
8.1.210.0000.00819.14
8.1.200.0030.00617.60
8.1.190.0030.00517.91
8.1.180.0040.00418.10
8.1.170.0080.00018.96
8.1.160.0070.00019.14
8.1.150.0060.00318.91
8.1.140.0000.00717.59
8.1.130.0070.00018.02
8.1.120.0070.00017.71
8.1.110.0000.00817.76
8.1.100.0000.00717.79
8.1.90.0030.00517.71
8.1.80.0050.00217.63
8.1.70.0050.00217.66
8.1.60.0000.00817.91
8.1.50.0000.00817.71
8.1.40.0050.00217.75
8.1.30.0040.00417.96
8.1.20.0000.00817.95
8.1.10.0030.00617.92
8.1.00.0040.00417.86
8.0.300.0060.00320.35
8.0.290.0030.00317.43
8.0.280.0030.00318.69
8.0.270.0030.00617.59
8.0.260.0030.00317.22
8.0.250.0000.00817.20
8.0.240.0040.00417.27
8.0.230.0070.00017.35
8.0.220.0000.00717.10
8.0.210.0040.00417.27
8.0.200.0000.00617.15
8.0.190.0000.00717.14
8.0.180.0040.00417.25
8.0.170.0040.00417.16
8.0.160.0040.00417.18
8.0.150.0040.00417.15
8.0.140.0030.00317.15
8.0.130.0000.00613.64
8.0.120.0040.00417.24
8.0.110.0050.00217.34
8.0.100.0050.00217.28
8.0.90.0030.00517.25
8.0.80.0120.00617.16
8.0.70.0000.00817.35
8.0.60.0000.00817.11
8.0.50.0000.00717.01
8.0.30.0120.00617.42
8.0.20.0140.00717.44
8.0.10.0040.00417.17
8.0.00.0110.00817.13
7.4.330.0000.00517.07
7.4.320.0030.00316.74
7.4.300.0000.00616.90
7.4.290.0000.00816.77
7.4.280.0040.00416.72
7.4.270.0070.00016.79
7.4.260.0030.00313.55
7.4.250.0000.00816.83
7.4.240.0040.00416.92
7.4.230.0050.00316.83
7.4.220.0060.01816.74
7.4.210.0100.00816.78
7.4.200.0070.00016.98
7.4.190.0000.00817.06
7.4.160.0130.00316.75
7.4.150.0060.01217.40
7.4.140.0100.01117.86
7.4.130.0130.00616.91
7.4.120.0100.00716.77
7.4.110.0100.00716.62
7.4.100.0120.00616.62
7.4.90.0080.00816.83
7.4.80.0100.00719.39
7.4.70.0090.00916.71
7.4.60.0130.00716.69
7.4.50.0040.00416.97
7.4.40.0070.01122.77
7.4.30.0110.00516.74
7.4.00.0120.00515.19
7.3.330.0030.00313.69
7.3.320.0000.00613.61
7.3.310.0070.00016.65
7.3.300.0020.00516.56
7.3.290.0110.00416.76
7.3.280.0100.00716.74
7.3.270.0070.01417.40
7.3.260.0160.00518.24
7.3.250.0110.01316.74
7.3.240.0030.01316.74
7.3.230.0120.00916.77
7.3.210.0030.01316.77
7.3.200.0120.01219.39
7.3.190.0100.00616.67
7.3.180.0080.00816.79
7.3.170.0070.01016.71
7.3.160.0080.00816.82
7.3.120.0100.00715.12
7.3.110.0070.01315.05
7.3.100.0120.00415.14
7.3.90.0030.01215.06
7.3.80.0140.00314.97
7.3.70.0040.01115.14
7.3.60.0040.00815.00
7.3.50.0070.01015.20
7.3.40.0060.00915.13
7.3.30.0040.01114.87
7.3.20.0030.00616.95
7.3.10.0120.00416.63
7.3.00.0090.00616.84
7.2.330.0100.00716.86
7.2.320.0090.00917.09
7.2.310.0100.01017.11
7.2.300.0160.00616.99
7.2.290.0130.00317.11
7.2.250.0030.01215.32
7.2.240.0100.00615.23
7.2.230.0070.00715.34
7.2.220.0040.00815.15
7.2.210.0070.01014.99
7.2.200.0000.01215.13
7.2.190.0060.00315.18
7.2.180.0090.00615.20
7.2.170.0090.00915.20
7.2.80.0100.00716.71
7.2.60.0030.01417.12
7.2.00.0000.01219.51
7.1.330.0000.01315.91
7.1.320.0060.00916.13
7.1.310.0070.01115.81
7.1.300.0040.01115.77
7.1.290.0060.01215.72
7.1.280.0000.01615.88
7.1.270.0120.00315.86
7.1.260.0090.00315.93
7.1.200.0030.00715.91
7.1.100.0030.00818.23
7.1.70.0040.00417.31
7.1.60.0100.01319.40
7.1.50.0030.00716.68
7.1.00.0000.03722.45
7.0.200.0070.00016.74
7.0.140.0000.07022.14
7.0.100.0170.09320.27
7.0.90.0230.04020.05
7.0.80.0070.07320.07
7.0.70.0070.07720.26
7.0.60.0030.06720.00
7.0.50.0100.07720.48
7.0.40.0230.03320.16
7.0.30.0070.05020.25
7.0.20.0030.09020.15
7.0.10.0170.07020.14
7.0.00.0030.09020.20
5.6.280.0030.07321.18
5.6.250.0070.08020.79
5.6.240.0030.04020.85
5.6.230.0000.09020.60
5.6.220.0030.04020.58
5.6.210.0030.08020.69
5.6.200.0070.08021.03
5.6.190.0070.08721.23
5.6.180.0100.07021.25
5.6.170.0070.09021.22
5.6.160.0070.04021.14
5.6.150.0070.05721.13
5.6.140.0100.08321.12
5.6.130.0200.05021.02
5.6.120.0030.08021.11
5.6.110.0000.07721.14
5.6.100.0100.08321.19
5.6.90.0100.04021.24
5.6.80.0100.07020.56
5.6.70.0100.04320.63
5.6.60.0070.07020.39
5.6.50.0070.06320.65
5.6.40.0100.06720.44
5.6.30.0070.06320.54
5.6.20.0070.08020.64
5.6.10.0030.08720.63
5.6.00.0070.07720.57
5.5.380.0100.07020.46
5.5.370.0030.04020.59
5.5.360.0030.08720.47
5.5.350.0130.07720.61
5.5.340.0100.05320.92
5.5.330.0100.07321.03
5.5.320.0170.07721.05
5.5.310.0000.08020.91
5.5.300.0100.07720.82
5.5.290.0070.07320.92
5.5.280.0030.04321.05
5.5.270.0100.08720.86
5.5.260.0070.04720.95
5.5.250.0030.08320.68
5.5.240.0000.04320.26
5.5.230.0000.05020.41
5.5.220.0030.04720.32
5.5.210.0100.06320.21
5.5.200.0100.07320.25
5.5.190.0070.05020.33
5.5.180.0100.06720.32
5.5.160.0100.07020.22
5.5.150.0030.04020.21
5.5.140.0070.04320.38
5.5.130.0030.06320.24
5.5.120.0170.05720.34
5.5.110.0100.07320.29
5.5.100.0030.08320.13
5.5.90.0000.04020.28
5.5.80.0070.03320.13
5.5.70.0100.07320.25
5.5.60.0170.06320.16
5.5.50.0070.06719.98
5.5.40.0030.03720.09
5.5.30.0100.07320.12
5.5.20.0070.08020.25
5.5.10.0070.08020.23
5.5.00.0030.07320.25
5.4.450.0130.03319.59
5.4.440.0100.04719.35
5.4.430.0170.06719.34
5.4.420.0030.04719.58
5.4.410.0030.08319.32
5.4.400.0100.06318.93
5.4.390.0200.06319.23
5.4.380.0030.08019.26
5.4.370.0030.07719.23
5.4.360.0070.03719.29
5.4.350.0070.08019.28
5.4.340.0130.04019.08
5.4.320.0070.07018.93
5.4.310.0130.03719.19
5.4.300.0000.06719.25
5.4.290.0070.07319.25
5.4.280.0030.07319.10
5.4.270.0070.04319.12
5.4.260.0000.05018.95
5.4.250.0070.05719.25
5.4.240.0070.07019.02
5.4.230.0000.04019.25
5.4.220.0100.03319.22
5.4.210.0030.07319.37
5.4.200.0070.07019.10
5.4.190.0000.07719.23
5.4.180.0070.04719.36
5.4.170.0130.05319.36
5.4.160.0030.08319.24
5.4.150.0070.07719.24
5.4.140.0070.07316.52
5.4.130.0100.06316.51
5.4.120.0070.07016.64
5.4.110.0100.07016.77
5.4.100.0030.06716.77
5.4.90.0070.07016.53
5.4.80.0070.07016.75
5.4.70.0170.06016.58
5.4.60.0030.03716.47
5.4.50.0070.04016.55
5.4.40.0030.07716.59
5.4.30.0070.07016.55
5.4.20.0000.04316.46
5.4.10.0070.06316.51
5.4.00.0030.07716.07
5.3.290.0030.04714.71
5.3.280.0070.07714.64
5.3.270.0070.03314.79
5.3.260.0000.07714.67
5.3.250.0070.07314.73
5.3.240.0130.06314.84
5.3.230.0130.07014.84
5.3.220.0030.05314.72
5.3.210.0030.04014.85
5.3.200.0130.07314.73
5.3.190.0100.07014.84
5.3.180.0170.05714.71
5.3.170.0030.07314.70
5.3.160.0030.04314.61
5.3.150.0070.03314.71
5.3.140.0200.07014.74
5.3.130.0000.07014.58
5.3.120.0100.06714.77
5.3.110.0000.06314.78
5.3.100.0100.03314.18
5.3.90.0100.03314.08
5.3.80.0200.06314.26
5.3.70.0100.06714.18
5.3.60.0030.06714.24
5.3.50.0100.06314.07
5.3.40.0070.04014.11
5.3.30.0130.06714.14
5.3.20.0070.06713.95
5.3.10.0030.06713.90
5.3.00.0030.07313.72
5.2.170.0100.05712.68
5.2.160.0070.06012.68
5.2.150.0100.05312.68
5.2.140.0070.06012.68
5.2.130.0070.03312.68
5.2.120.0070.05312.68
5.2.110.0070.03012.68
5.2.100.0030.05712.68
5.2.90.0030.03712.68
5.2.80.0100.05012.68
5.2.70.0030.04312.68
5.2.60.0000.06012.68
5.2.50.0070.05312.68
5.2.40.0030.04712.68
5.2.30.0000.03712.68
5.2.20.0100.05712.68
5.2.10.0030.04712.68
5.2.00.0000.04012.68
5.1.60.0030.03712.68
5.1.50.0000.02712.68
5.1.40.0100.02312.68
5.1.30.0100.02012.68
5.1.20.0030.03012.68
5.1.10.0000.03012.68
5.1.00.0000.05712.68
5.0.50.0070.04312.68
5.0.40.0000.02312.68
5.0.30.0000.03312.68
5.0.20.0000.02012.68
5.0.10.0070.03712.68
5.0.00.0000.06712.68
4.4.90.0000.02012.68
4.4.80.0070.01012.68
4.4.70.0030.02312.68
4.4.60.0000.03312.68
4.4.50.0070.02012.68
4.4.40.0100.03312.68
4.4.30.0000.01712.68
4.4.20.0000.03012.68
4.4.10.0000.02012.68
4.4.00.0000.04312.68
4.3.110.0000.01712.68
4.3.100.0000.03312.68
4.3.90.0070.01012.68
4.3.80.0030.05712.68
4.3.70.0000.03012.68
4.3.60.0100.02012.68
4.3.50.0030.03312.68
4.3.40.0000.02312.68
4.3.30.0000.02012.68
4.3.20.0000.02012.68
4.3.10.0000.01712.68
4.3.00.0000.01712.68

preferences:
43.29 ms | 401 KiB | 5 Q