3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $filePath; private $isUrl; 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; } if ($this->xml->$offset->count() > 1) { return new self($this->xml->$offset->asXML(), false); } var_dump($this->xml->$offset->asXML()); return $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('test.xml', false); echo $xml['note']['to']; //var_dump($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.70.0070.01116.88
8.3.60.0070.01019.06
8.3.50.0110.00821.33
8.3.40.0120.00618.88
8.3.30.0040.01119.07
8.3.20.0050.00319.23
8.3.10.0080.00020.96
8.3.00.0040.00424.04
8.2.180.0070.01418.91
8.2.170.0220.00022.96
8.2.160.0070.01020.47
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00619.48
8.2.110.0100.00022.38
8.2.100.0100.00317.97
8.2.90.0050.00319.30
8.2.80.0080.00018.18
8.2.70.0070.00317.75
8.2.60.0050.00318.18
8.2.50.0030.00818.07
8.2.40.0050.00318.34
8.2.30.0000.00820.13
8.2.20.0000.00817.92
8.2.10.0050.00317.92
8.2.00.0030.00618.10
8.1.280.0000.01425.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.59
8.1.230.0060.00620.87
8.1.220.0030.00618.77
8.1.210.0030.00519.16
8.1.200.0030.00617.38
8.1.190.0000.00917.78
8.1.180.0080.00018.10
8.1.170.0030.00519.03
8.1.160.0070.00019.22
8.1.150.0040.00418.86
8.1.140.0000.00817.66
8.1.130.0040.00417.93
8.1.120.0040.00417.59
8.1.110.0000.00817.81
8.1.100.0000.00717.67
8.1.90.0050.00317.55
8.1.80.0070.00017.79
8.1.70.0070.00017.67
8.1.60.0000.00817.71
8.1.50.0000.00817.55
8.1.40.0000.00917.66
8.1.30.0040.00417.87
8.1.20.0040.00417.80
8.1.10.0060.00317.70
8.1.00.0040.00417.59
8.0.300.0060.00320.20
8.0.290.0000.00717.00
8.0.280.0030.00318.70
8.0.270.0000.00717.59
8.0.260.0070.00016.99
8.0.250.0000.00717.27
8.0.240.0030.00617.23
8.0.230.0000.00717.05
8.0.220.0000.00717.12
8.0.210.0030.00317.18
8.0.200.0060.00017.34
8.0.190.0000.00717.17
8.0.180.0000.00817.09
8.0.170.0000.00817.20
8.0.160.0050.00217.16
8.0.150.0000.01017.19
8.0.140.0060.00617.23
8.0.130.0070.00013.65
8.0.120.0050.00317.21
8.0.110.0000.00817.20
8.0.100.0040.00417.14
8.0.90.0070.00017.17
8.0.80.0060.01217.13
8.0.70.0040.00417.16
8.0.60.0000.00717.18
8.0.50.0000.00817.10
8.0.30.0080.01017.36
8.0.20.0090.01217.40
8.0.10.0000.00817.16
8.0.00.0060.01217.15
7.4.330.0030.00313.43
7.4.320.0000.00716.71
7.4.300.0060.00016.84
7.4.290.0080.00016.61
7.4.280.0040.00416.77
7.4.270.0000.00816.75
7.4.260.0000.00613.45
7.4.250.0050.00216.78
7.4.240.0080.00016.68
7.4.230.0050.00316.70
7.4.220.0040.01116.76
7.4.210.0090.00716.82
7.4.200.0040.00416.47
7.4.190.0070.00016.90
7.4.160.0130.00316.76
7.4.150.0070.01117.40
7.4.140.0090.00917.86
7.4.130.0120.01216.84
7.4.120.0160.00416.66
7.4.110.0030.01416.86
7.4.100.0090.00816.91
7.4.90.0110.00616.77
7.4.80.0030.01319.04
7.4.70.0090.00816.81
7.4.60.0030.01316.71
7.4.50.0000.01016.51
7.4.40.0100.00722.27
7.4.30.0110.00716.75
7.4.10.0070.01115.29
7.4.00.0030.01315.00
7.3.330.0050.00013.40
7.3.320.0050.00013.33
7.3.310.0030.00516.43
7.3.300.0000.00616.58
7.3.290.0130.00616.58
7.3.280.0070.01016.56
7.3.270.0100.00717.40
7.3.260.0080.01118.24
7.3.250.0090.00816.71
7.3.240.0110.00716.59
7.3.230.0060.01216.59
7.3.210.0090.01216.71
7.3.200.0030.01419.39
7.3.190.0110.01116.71
7.3.180.0130.00316.50
7.3.170.0070.01116.69
7.3.160.0030.01216.59
7.3.130.0100.00715.02
7.3.120.0080.01115.04
7.3.110.0080.01114.97
7.3.100.0050.00914.87
7.3.90.0080.01015.05
7.3.80.0060.00514.95
7.3.70.0100.00414.97
7.3.60.0060.00814.94
7.3.50.0040.00714.81
7.3.40.0080.00414.67
7.3.30.0030.00814.97
7.3.20.0060.00716.83
7.3.10.0070.00716.68
7.3.00.0060.00316.78
7.2.330.0070.01016.89
7.2.320.0110.00616.91
7.2.310.0030.01716.91
7.2.300.0160.00616.57
7.2.290.0100.01016.55
7.2.260.0110.00714.94
7.2.250.0080.01015.04
7.2.240.0030.01415.16
7.2.230.0000.01615.12
7.2.220.0050.01015.38
7.2.210.0020.01215.10
7.2.200.0030.01115.01
7.2.190.0080.00315.16
7.2.180.0060.00615.08
7.2.170.0060.00615.01
7.2.160.0040.01215.02
7.2.150.0000.01516.71
7.2.140.0060.00916.86
7.2.130.0060.00616.83
7.2.120.0060.00916.74
7.2.110.0030.01016.88
7.2.100.0070.00316.78
7.2.90.0100.00717.11
7.2.80.0070.01016.72
7.2.70.0030.00716.86
7.2.60.0090.00316.92
7.2.50.0100.00617.11
7.2.40.0030.00616.63
7.2.30.0040.00716.80
7.2.20.0030.00917.14
7.2.10.0130.00016.66
7.2.00.0000.01116.91
7.1.330.0020.01315.88
7.1.320.0050.00915.92
7.1.310.0100.00715.74
7.1.300.0090.00515.75
7.1.290.0060.00815.87
7.1.280.0110.00515.80
7.1.270.0080.00315.88
7.1.260.0050.01015.87
7.1.250.0040.01115.80
7.1.240.0080.00015.62
7.1.230.0070.00715.82
7.1.220.0000.01215.88
7.1.210.0120.00015.75
7.1.200.0070.00716.00
7.1.190.0070.00315.99
7.1.180.0030.00915.78
7.1.170.0040.01115.99
7.1.160.0030.00516.12
7.1.150.0070.00715.62
7.1.140.0110.00315.69
7.1.130.0000.01415.86
7.1.120.0030.00715.96
7.1.110.0000.01315.89
7.1.100.0060.00616.09
7.1.90.0030.01015.84
7.1.80.0040.00715.57
7.1.70.0060.00416.53
7.1.60.0050.01117.54
7.1.50.0050.01116.42
7.1.40.0030.01215.88
7.1.30.0040.01116.09
7.1.20.0070.00716.02
7.1.10.0090.00615.76
7.1.00.0020.02219.19
7.0.330.0100.00315.46
7.0.320.0030.01015.59
7.0.310.0070.00715.27
7.0.300.0090.00315.51
7.0.290.0040.00415.55
7.0.280.0100.00315.28
7.0.270.0030.00715.63
7.0.260.0030.00615.45
7.0.250.0070.00715.36
7.0.240.0030.01015.72
7.0.230.0100.00315.66
7.0.220.0000.01215.53
7.0.210.0040.00815.57
7.0.200.0030.00716.22
7.0.190.0030.01015.54
7.0.180.0000.01515.66
7.0.170.0000.01415.55
7.0.160.0120.00315.74
7.0.150.0000.00815.68
7.0.140.0000.04118.81
7.0.130.0000.01415.53
7.0.120.0030.00915.52
7.0.110.0030.00615.48
7.0.100.0080.00415.70
7.0.90.0030.00715.51
7.0.80.0000.01415.52
7.0.70.0070.00715.63
7.0.60.0070.04217.82
7.0.50.0060.03316.85
7.0.40.0060.03916.82
7.0.30.0180.04116.88
7.0.20.0180.03816.85
7.0.10.0020.04116.86
7.0.00.0050.03316.79
5.6.400.0030.01214.80
5.6.390.0060.00914.47
5.6.380.0060.00314.62
5.6.370.0000.00914.78
5.6.360.0000.01514.60
5.6.350.0000.00914.47
5.6.340.0130.00014.77
5.6.330.0060.00614.38
5.6.320.0070.00714.18
5.6.310.0100.00614.64
5.6.300.0030.01014.34
5.6.290.0030.01013.96
5.6.280.0030.04317.79
5.6.270.0030.00814.64
5.6.260.0030.00914.46
5.6.250.0070.00714.45
5.6.240.0070.00714.34
5.6.230.0080.00014.33
5.6.220.0070.00714.40
5.6.210.0040.04417.67
5.6.200.0100.01816.36
5.6.190.0120.03417.69
5.6.180.0170.04317.72
5.6.170.0230.03717.47
5.6.160.0050.03817.51
5.6.150.0120.03816.24
5.6.140.0030.03416.48
5.6.130.0030.04416.38
5.6.120.0050.03017.92
5.6.110.0000.03117.86
5.6.100.0080.04317.76
5.6.90.0060.02417.63
5.6.80.0080.04217.49
5.6.70.0030.01014.27
5.6.60.0060.00614.61
5.6.50.0070.00714.29
5.6.40.0030.00914.51
5.6.30.0040.00914.17
5.6.20.0000.00814.64
5.6.10.0060.01314.45
5.6.00.0040.00714.45
5.5.380.0030.01014.15
5.5.370.0030.01014.48
5.5.360.0070.01114.41
5.5.350.2180.02417.45
5.5.340.0060.04116.29
5.5.330.0140.04017.14
5.5.320.0070.02817.47
5.5.310.0120.02917.47
5.5.300.0030.03016.28
5.5.290.0100.04016.19
5.5.280.0020.03017.82
5.5.270.0080.03517.68
5.5.260.0080.04317.42
5.5.250.0050.03817.52
5.5.240.0200.03817.23
5.5.230.0090.00314.06
5.5.220.0060.00914.55
5.5.210.0070.00414.32
5.5.200.0060.00614.20
5.5.190.0000.00814.43
5.5.180.0000.00814.19
5.5.170.0030.01014.53
5.5.160.0090.00614.23
5.5.150.0070.00314.51
5.5.140.0000.01114.55
5.5.130.0100.00614.18
5.5.120.0030.00914.20
5.5.110.0100.00714.59
5.5.100.0040.01114.26
5.5.90.0140.00014.33
5.5.80.0110.00414.14
5.5.70.0000.01014.49
5.5.60.0030.00714.25
5.5.50.0000.00814.57
5.5.40.0040.01114.35
5.5.30.0030.01014.13
5.5.20.0090.00614.38
5.5.10.0080.00414.32
5.5.00.0040.00714.54
5.4.450.0080.03315.70
5.4.440.0060.02815.88
5.4.430.0100.04215.70
5.4.420.0120.01915.85
5.4.410.0080.04015.79
5.4.400.0070.03315.70
5.4.390.0120.04515.62
5.4.380.0100.02815.58
5.4.370.0080.02515.61
5.4.360.0070.02315.58
5.4.350.0110.02315.71
5.4.340.0090.02715.60
5.4.330.0060.00812.04
5.4.320.0100.03115.71
5.4.310.0070.04515.59
5.4.300.0100.02215.54
5.4.290.0120.04215.70
5.4.280.0180.02315.67
5.4.270.0070.03115.62
5.4.260.0080.02415.61
5.4.250.0110.03115.59
5.4.240.0110.02515.71
5.4.230.0080.02915.59
5.4.220.0120.02515.69
5.4.210.0050.03915.60
5.4.200.0080.03415.57
5.4.190.0140.03815.53
5.4.180.0140.03615.57
5.4.170.0070.02715.60
5.4.160.0080.04315.59
5.4.150.0080.03315.52
5.4.140.0120.02014.24
5.4.130.0070.02014.33
5.4.120.0050.02214.28
5.4.110.0030.02614.29
5.4.100.0080.01814.36
5.4.90.0050.02214.37
5.4.80.0070.02314.36
5.4.70.0050.02514.30
5.4.60.0050.02014.27
5.4.50.0030.02414.29
5.4.40.0050.02314.36
5.4.30.0070.02314.37
5.4.20.0060.02114.34
5.4.10.0110.02314.36
5.4.00.0100.01514.04
5.3.290.0100.02013.47
5.3.280.0030.02713.35
5.3.270.0100.01713.43
5.3.260.0030.02513.35
5.3.250.0070.01913.36
5.3.240.0060.02113.43
5.3.230.0100.01813.35
5.3.220.0050.02313.43
5.3.210.0110.02113.34
5.3.200.0080.01813.44
5.3.190.0080.02013.46
5.3.180.0090.01713.34
5.3.170.0050.02313.41
5.3.160.0070.02213.46
5.3.150.0050.02213.36
5.3.140.0050.02213.41
5.3.130.0050.02413.41
5.3.120.0100.01813.43
5.3.110.0090.01913.33
5.3.100.0070.02213.10
5.3.90.0050.02213.12
5.3.80.0070.02113.06
5.3.70.0070.02113.06
5.3.60.0080.01913.05
5.3.50.0060.02113.05
5.3.40.0090.01913.03
5.3.30.0030.02313.13
5.3.20.0050.02212.90
5.3.10.0080.02012.86
5.3.00.0090.01912.87
5.2.170.0070.03012.23
5.2.160.0130.03012.23
5.2.150.0000.03312.23
5.2.140.0030.04012.23
5.2.130.0100.02312.23
5.2.120.0030.02712.23
5.2.110.0100.02712.23
5.2.100.0030.03312.23
5.2.90.0100.02312.23
5.2.80.0130.02312.23
5.2.70.0100.02712.23
5.2.60.0070.04712.23
5.2.50.0130.02312.23
5.2.40.0000.03012.23
5.2.30.0030.04012.23
5.2.20.0070.02712.23
5.2.10.0070.02312.23
5.2.00.0070.02312.23
5.1.60.0030.03012.23
5.1.50.0130.01712.23
5.1.40.0030.02312.23
5.1.30.0030.02712.23
5.1.20.0130.01712.23
5.1.10.0030.02712.23
5.1.00.0030.02712.23
5.0.50.0000.02312.23
5.0.40.0000.02012.23
5.0.30.0000.03012.23
5.0.20.0000.01712.23
5.0.10.0000.02312.23
5.0.00.0030.02712.23
4.4.90.0070.01012.23
4.4.80.0000.01312.23
4.4.70.0030.01312.23
4.4.60.0000.01312.23
4.4.50.0030.01312.23
4.4.40.0000.02312.23
4.4.30.0030.01712.23
4.4.20.0000.02012.23
4.4.10.0000.01312.23
4.4.00.0000.02312.23
4.3.110.0000.01712.23
4.3.100.0000.01712.23
4.3.90.0000.01712.23
4.3.80.0030.02312.23
4.3.70.0000.01712.23
4.3.60.0000.02012.23
4.3.50.0030.01712.23
4.3.40.0000.05312.23
4.3.30.0000.02012.23
4.3.20.0000.02712.23
4.3.10.0000.03712.23
4.3.00.0100.01312.23

preferences:
39.24 ms | 401 KiB | 5 Q