3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $iterator; public function __construct($filePath, $isUrl = true) { $this->isUrl = $isUrl; $this->iterator = $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 $this->iterator = new ArrayIterator((array)$this->xml->$offset); } public function __toString() { return (string) $this->iterator[0]; } 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()); echo $xml;

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.0140.00718.93
8.3.50.0120.00622.05
8.3.40.0180.00419.21
8.3.30.0090.00619.05
8.3.20.0050.00319.10
8.3.10.0030.00521.17
8.3.00.0040.00423.75
8.2.180.0070.01117.00
8.2.170.0120.00322.96
8.2.160.0100.00320.52
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00420.02
8.2.110.0040.00720.54
8.2.100.0090.00318.16
8.2.90.0040.00419.34
8.2.80.0060.00318.28
8.2.70.0040.00417.88
8.2.60.0040.00418.18
8.2.50.0080.00018.07
8.2.40.0060.00318.47
8.2.30.0040.00419.60
8.2.20.0000.00718.02
8.2.10.0030.00518.00
8.2.00.0000.00817.98
8.1.280.0100.01025.92
8.1.270.0040.00423.99
8.1.260.0060.00826.35
8.1.250.0100.00028.09
8.1.240.0030.00622.84
8.1.230.0040.00821.09
8.1.220.0080.00018.77
8.1.210.0000.00819.15
8.1.200.0030.00617.73
8.1.190.0080.00017.77
8.1.180.0040.00418.10
8.1.170.0040.00418.84
8.1.160.0000.00819.09
8.1.150.0000.00718.89
8.1.140.0000.01017.58
8.1.130.0000.00718.12
8.1.120.0020.00517.61
8.1.110.0000.01117.61
8.1.100.0000.00917.68
8.1.90.0000.00717.63
8.1.80.0040.00417.61
8.1.70.0070.00017.61
8.1.60.0060.00317.73
8.1.50.0040.00417.72
8.1.40.0090.00017.79
8.1.30.0040.00417.74
8.1.20.0000.00817.73
8.1.10.0040.00417.69
8.1.00.0040.00417.67
8.0.300.0000.00720.46
8.0.290.0040.00417.41
8.0.280.0070.00018.68
8.0.270.0000.00817.34
8.0.260.0000.01017.11
8.0.250.0050.00217.22
8.0.240.0070.00017.26
8.0.230.0070.00017.22
8.0.220.0000.00817.16
8.0.210.0050.00317.08
8.0.200.0000.00617.19
8.0.190.0040.00417.16
8.0.180.0050.00217.19
8.0.170.0070.00017.09
8.0.160.0000.00717.25
8.0.150.0040.00417.09
8.0.140.0080.00417.09
8.0.130.0040.00413.55
8.0.120.0070.00017.08
8.0.110.0000.00716.95
8.0.100.0000.00717.05
8.0.90.0050.00217.17
8.0.80.0040.01117.18
8.0.70.0000.00717.07
8.0.60.0000.00717.02
8.0.50.0040.00417.06
8.0.30.0160.00517.42
8.0.20.0150.00617.60
8.0.10.0040.00417.36
8.0.00.0060.01116.97
7.4.330.0040.00413.43
7.4.320.0070.00016.80
7.4.300.0040.00416.79
7.4.290.0000.00816.88
7.4.280.0000.00816.77
7.4.270.0030.00516.86
7.4.260.0030.00313.49
7.4.250.0040.00416.57
7.4.240.0000.00716.89
7.4.230.0000.00816.86
7.4.220.0150.00316.85
7.4.210.0090.00916.79
7.4.200.0040.00416.95
7.4.190.0070.00016.75
7.4.160.0150.00716.80
7.4.150.0070.01117.40
7.4.140.0170.00317.86
7.4.130.0110.00716.83
7.4.120.0120.00616.74
7.4.110.0090.00916.84
7.4.100.0150.00316.72
7.4.90.0120.01016.87
7.4.80.0060.01119.39
7.4.70.0120.00616.95
7.4.60.0040.01816.61
7.4.50.0060.00316.61
7.4.40.0120.00422.52
7.4.30.0100.00616.82
7.4.00.0070.01115.17
7.3.330.0000.00513.57
7.3.320.0000.00513.54
7.3.310.0000.00716.75
7.3.300.0030.00316.61
7.3.290.0130.00316.64
7.3.280.0070.01016.62
7.3.270.0060.01217.40
7.3.260.0130.00618.24
7.3.250.0110.00616.72
7.3.240.0120.00416.83
7.3.230.0110.00816.68
7.3.210.0060.01216.64
7.3.200.0090.01519.39
7.3.190.0090.00616.70
7.3.180.0090.00816.71
7.3.170.0060.00916.73
7.3.160.0060.01516.75
7.3.120.0070.00815.06
7.3.110.0130.00315.21
7.3.100.0040.01115.11
7.3.90.0090.00614.71
7.3.80.0110.00715.07
7.3.70.0120.00315.26
7.3.60.0090.00614.79
7.3.50.0040.01414.74
7.3.40.0080.00614.97
7.3.30.0080.00615.13
7.3.20.0100.00316.91
7.3.10.0070.00716.89
7.3.00.0090.00616.99
7.2.330.0070.01116.86
7.2.320.0070.01116.95
7.2.310.0100.01316.92
7.2.300.0080.00816.90
7.2.290.0060.01016.96
7.2.250.0090.00915.41
7.2.240.0030.01615.48
7.2.230.0030.01015.02
7.2.220.0040.01115.34
7.2.210.0030.01315.05
7.2.200.0060.01215.31
7.2.190.0070.01115.14
7.2.180.0110.00715.28
7.2.170.0030.00715.20
7.2.80.0150.00616.59
7.2.60.0000.00917.18
7.2.00.0090.00019.60
7.1.330.0090.00315.86
7.1.320.0060.00915.66
7.1.310.0040.01115.84
7.1.300.0030.01415.81
7.1.290.0060.00316.01
7.1.280.0040.00715.79
7.1.270.0100.00316.04
7.1.260.0030.01015.83
7.1.200.0090.00615.75
7.1.100.0040.00818.00
7.1.70.0030.01017.16
7.1.60.0110.01519.40
7.1.50.0310.00735.03
7.1.00.0070.07322.54
7.0.200.0050.00216.54
7.0.140.0100.06722.14
7.0.70.0030.05721.80
7.0.60.0000.06321.93
7.0.50.0030.08722.16
7.0.40.0030.08720.24
7.0.30.0000.09020.07
7.0.20.0030.04020.24
7.0.10.0070.07720.26
7.0.00.0030.07320.18
5.6.280.0030.07321.03
5.6.220.0000.07020.77
5.6.210.0100.07720.59
5.6.200.0070.06321.21
5.6.190.0030.06721.07
5.6.180.0000.08721.15
5.6.170.0030.07720.99
5.6.160.0130.07721.16
5.6.150.0130.07321.12
5.6.140.0030.07321.10
5.6.130.0100.08021.13
5.6.120.0170.06721.27
5.6.110.0030.08320.98
5.6.100.0030.09021.16
5.6.90.0030.05721.05
5.6.80.0170.05320.51
5.6.70.0030.08320.48
5.6.60.0000.06320.42
5.6.50.0070.06020.45
5.6.40.0000.05320.64
5.6.30.0000.06720.35
5.6.20.0030.08020.50
5.6.10.0000.08720.34
5.6.00.0030.08720.47
5.5.360.0100.06320.47
5.5.350.0030.08320.53
5.5.340.0000.08720.92
5.5.330.0000.08320.95
5.5.320.0030.04321.05
5.5.310.0000.05020.86
5.5.300.0070.08320.96
5.5.290.0000.08720.95
5.5.280.0100.08320.79
5.5.270.0000.08320.92
5.5.260.0000.09320.91
5.5.250.0030.07320.77
5.5.240.0100.07320.35
5.5.230.0070.07320.36
5.5.220.0100.07020.41
5.5.210.0030.07020.23
5.5.200.0000.05020.34
5.5.190.0100.03720.40
5.5.180.0030.08720.17
5.5.160.0070.08020.34
5.5.150.0130.07720.39
5.5.140.0030.08320.30
5.5.130.0000.08020.16
5.5.120.0070.07720.40
5.5.110.0100.06320.23
5.5.100.0100.06320.29
5.5.90.0000.05320.10
5.5.80.0000.08020.22
5.5.70.0070.08020.14
5.5.60.0030.06020.14
5.5.50.0030.05020.14
5.5.40.0030.05020.11
5.5.30.0070.07320.21
5.5.20.0000.05020.25
5.5.10.0070.04320.12
5.5.00.0000.04020.23
5.4.450.0030.08019.35
5.4.440.0100.04719.55
5.4.430.0000.06019.26
5.4.420.0030.08019.54
5.4.410.0000.08019.39
5.4.400.0030.04719.26
5.4.390.0000.07019.27
5.4.380.0000.08319.23
5.4.370.0100.07019.12
5.4.360.0000.08719.25
5.4.350.0070.05319.02
5.4.340.0070.08019.36
5.4.320.0130.07319.24
5.4.310.0000.07319.12
5.4.300.0070.07719.23
5.4.290.0100.07319.27
5.4.280.0000.06319.30
5.4.270.0070.04319.36
5.4.260.0100.07019.02
5.4.250.0000.06019.22
5.4.240.0030.06719.18
5.4.230.0030.08019.11
5.4.220.0030.06018.91
5.4.210.0130.06719.11
5.4.200.0070.07319.23
5.4.190.0100.07019.21
5.4.180.0000.08319.24
5.4.170.0030.03719.22
5.4.160.0030.03719.25
5.4.150.0070.03319.25
5.4.140.0000.03716.54
5.4.130.0000.03716.61
5.4.120.0000.03716.54
5.4.110.0000.03716.58
5.4.100.0000.04316.55
5.4.90.0030.03316.61
5.4.80.0030.02716.64
5.4.70.0030.03316.54
5.4.60.0000.03716.55
5.4.50.0000.07716.53
5.4.40.0000.04016.57
5.4.30.0070.03016.43
5.4.20.0030.04016.55
5.4.10.0030.07316.45
5.4.00.0000.04016.06
5.3.290.0030.07014.87
5.3.280.0070.05714.75
5.3.270.0130.05714.84
5.3.260.0000.06314.75
5.3.250.0000.03714.86
5.3.240.0000.04314.75
5.3.230.0000.04014.74
5.3.220.0070.03014.58
5.3.210.0030.04714.61
5.3.200.0030.05714.76
5.3.190.0030.03314.74
5.3.180.0000.03014.59
5.3.170.0000.03714.69
5.3.160.0030.03314.82
5.3.150.0000.06014.79
5.3.140.0000.06314.64
5.3.130.0100.07014.70
5.3.120.0000.06714.68
5.3.110.0070.04314.73
5.3.100.0030.05714.25
5.3.90.0000.03714.24
5.3.80.0000.07314.28
5.3.70.0000.03714.14
5.3.60.0030.04714.01
5.3.50.0000.04014.04
5.3.40.0000.05014.09
5.3.30.0030.04714.11
5.3.20.0000.03713.84
5.3.10.0000.03313.80
5.3.00.0000.03713.89
5.2.170.0030.03312.79
5.2.160.0000.05312.79
5.2.150.0000.05012.79
5.2.140.0030.03012.79
5.2.130.0070.02312.79
5.2.120.0030.03012.79
5.2.110.0000.03012.79
5.2.100.0000.03012.79
5.2.90.0030.04012.79
5.2.80.0030.02712.79
5.2.70.0030.03312.79
5.2.60.0000.03012.79
5.2.50.0030.05012.79
5.2.40.0000.03012.79
5.2.30.0030.02712.79
5.2.20.0070.02312.79
5.2.10.0000.03012.79
5.2.00.0030.03312.79
5.1.60.0000.02312.79
5.1.50.0030.02312.79
5.1.40.0070.03712.79
5.1.30.0000.03312.79
5.1.20.0030.02712.79
5.1.10.0000.02712.79
5.1.00.0030.02712.79
5.0.50.0030.02312.79
5.0.40.0030.02012.79
5.0.30.0000.03012.79
5.0.20.0000.04012.79
5.0.10.0000.02012.79
5.0.00.0000.03312.79
4.4.90.0000.01712.79
4.4.80.0000.03012.79
4.4.70.0000.03012.79
4.4.60.0000.01312.79
4.4.50.0000.01712.79
4.4.40.0030.02012.79
4.4.30.0000.02312.79
4.4.20.0000.01312.79
4.4.10.0030.01312.79
4.4.00.0000.04312.79
4.3.110.0000.02312.79
4.3.100.0000.01712.79
4.3.90.0000.01712.79
4.3.80.0000.02712.79
4.3.70.0030.01312.79
4.3.60.0000.01312.79
4.3.50.0000.01712.79
4.3.40.0000.02312.79
4.3.30.0000.01712.79
4.3.20.0000.02012.79
4.3.10.0000.01712.79
4.3.00.0000.01312.79

preferences:
56.23 ms | 401 KiB | 5 Q