3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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; } if (preg_match('/(\w+)\[(\d+)\]/', $offset, $nodes)) { $node = $nodes[1]; $key = $nodes[2]; var_dump($this->xml->$node->children[$key]->asXML()); return new self($this->xml->$node[$key]->asXML(), false); } return new self($this->xml->$offset->asXML(), false); } 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']; $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.0040.01118.80
8.3.50.0100.01122.30
8.3.40.0060.00919.34
8.3.30.0070.00719.59
8.3.20.0090.00920.63
8.3.10.0080.00022.10
8.3.00.0030.00522.64
8.2.180.0140.00717.25
8.2.170.0070.01122.96
8.2.160.0110.00419.55
8.2.150.0040.00424.18
8.2.140.0110.01124.66
8.2.130.0040.00426.16
8.2.120.0040.00420.02
8.2.110.0090.00019.54
8.2.100.0040.00718.41
8.2.90.0050.00319.42
8.2.80.0090.00018.13
8.2.70.0030.00618.00
8.2.60.0040.00418.30
8.2.50.0040.00418.10
8.2.40.0000.00818.59
8.2.30.0040.00418.34
8.2.20.0050.00318.14
8.2.10.0040.00418.25
8.2.00.0030.00618.10
8.1.280.0070.00725.92
8.1.270.0040.00419.13
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0050.00523.00
8.1.230.0120.00018.01
8.1.220.0040.00417.93
8.1.210.0040.00418.77
8.1.200.0000.01017.73
8.1.190.0000.00817.73
8.1.180.0000.00818.10
8.1.170.0050.00319.13
8.1.160.0000.00722.31
8.1.150.0040.00419.13
8.1.140.0000.00717.89
8.1.130.0000.00718.00
8.1.120.0030.00417.91
8.1.110.0080.00017.89
8.1.100.0040.00417.91
8.1.90.0070.00017.87
8.1.80.0040.00417.89
8.1.70.0050.00217.84
8.1.60.0070.00418.01
8.1.50.0000.00817.94
8.1.40.0000.00817.89
8.1.30.0000.00817.95
8.1.20.0040.00418.13
8.1.10.0090.00018.05
8.1.00.0040.00418.01
8.0.300.0060.00318.77
8.0.290.0040.00417.38
8.0.280.0040.00418.77
8.0.270.0040.00417.50
8.0.260.0000.00717.30
8.0.250.0070.00017.31
8.0.240.0030.00617.43
8.0.230.0030.00317.44
8.0.220.0030.00517.40
8.0.210.0000.00717.39
8.0.200.0050.00317.46
8.0.190.0040.00417.40
8.0.180.0050.00217.31
8.0.170.0030.00517.39
8.0.160.0030.00517.32
8.0.150.0000.00717.35
8.0.140.0000.00817.26
8.0.130.0000.00613.79
8.0.120.0000.00817.28
8.0.110.0000.00817.36
8.0.100.0000.00817.26
8.0.90.0020.00517.39
8.0.80.0090.01317.33
8.0.70.0040.00417.47
8.0.60.0040.00417.46
8.0.50.0030.00517.23
8.0.30.0160.00517.60
8.0.20.0150.00417.40
8.0.10.0000.00717.58
8.0.00.0080.01417.33
7.4.330.0050.00015.00
7.4.320.0030.00317.02
7.4.300.0030.00317.09
7.4.290.0070.00316.90
7.4.280.0040.00417.07
7.4.270.0050.00316.87
7.4.260.0080.00017.07
7.4.250.0080.00017.10
7.4.240.0040.00416.99
7.4.230.0030.00317.01
7.4.220.0060.01016.90
7.4.210.0060.00917.02
7.4.200.0030.00317.09
7.4.190.0030.00417.16
7.4.160.0120.01217.21
7.4.150.0040.01417.40
7.4.140.0080.01017.86
7.4.130.0090.01117.07
7.4.120.0070.01017.08
7.4.110.0100.01317.12
7.4.100.0090.01317.14
7.4.90.0150.00617.07
7.4.80.0090.00919.39
7.4.70.0100.01017.11
7.4.60.0070.01017.12
7.4.50.0030.00616.79
7.4.40.0030.01022.77
7.4.30.0090.01817.04
7.4.10.0070.01015.45
7.4.00.0100.00715.29
7.3.330.0000.00513.65
7.3.320.0000.00513.74
7.3.310.0030.00316.95
7.3.300.0040.00416.86
7.3.290.0110.00916.86
7.3.280.0100.00716.85
7.3.270.0120.01217.40
7.3.260.0040.01416.84
7.3.250.0110.00716.83
7.3.240.0090.00916.76
7.3.230.0030.01316.86
7.3.210.0070.01016.82
7.3.200.0150.00319.39
7.3.190.0090.01216.89
7.3.180.0070.01716.93
7.3.170.0130.00316.88
7.3.160.0100.00717.05
7.3.130.0090.00815.23
7.3.120.0090.00615.22
7.3.110.0060.01115.33
7.3.100.0070.00715.26
7.3.90.0050.00715.22
7.3.80.0050.00615.30
7.3.70.0040.01015.22
7.3.60.0070.01015.20
7.3.50.0110.00815.31
7.3.40.0050.00815.22
7.3.30.0020.01215.01
7.3.20.0110.00616.89
7.3.10.0090.00516.94
7.3.00.0030.00816.91
7.2.330.0130.00717.17
7.2.320.0060.01517.11
7.2.310.0070.01317.05
7.2.300.0100.00717.04
7.2.290.0030.01416.98
7.2.260.0060.01115.59
7.2.250.0090.00615.25
7.2.240.0080.00715.34
7.2.230.0030.01215.37
7.2.220.0050.01415.44
7.2.210.0050.00815.34
7.2.200.0070.00715.21
7.2.190.0090.00815.38
7.2.180.0110.00715.32
7.2.170.0070.00815.41
7.2.160.0070.00415.17
7.2.150.0060.00617.21
7.2.140.0030.00917.17
7.2.130.0050.00817.10
7.2.120.0060.00817.14
7.2.110.0070.00717.18
7.2.100.0060.00817.01
7.2.90.0070.00817.10
7.2.80.0070.00917.24
7.2.70.0090.00417.14
7.2.60.0110.00517.25
7.2.50.0060.00817.19
7.2.40.0040.00817.25
7.2.30.0050.00817.16
7.2.20.0050.01217.16
7.2.10.0060.00917.20
7.2.00.0070.00617.58
7.1.330.0010.01216.23
7.1.320.0050.01016.16
7.1.310.0020.01216.10
7.1.300.0030.01016.09
7.1.290.0040.00916.18
7.1.280.0030.00916.00
7.1.270.0060.01016.20
7.1.260.0020.01416.09
7.1.250.0060.00716.00
7.1.240.0060.00416.17
7.1.230.0020.01215.92
7.1.220.0040.00716.06
7.1.210.0070.00516.09
7.1.200.0080.00716.11
7.1.190.0040.00915.94
7.1.180.0040.00916.13
7.1.170.0110.00216.11
7.1.160.0090.00716.07
7.1.150.0060.00816.12
7.1.140.0020.01316.13
7.1.130.0070.00516.13
7.1.120.0040.00716.26
7.1.110.0030.01016.18
7.1.100.0040.00816.86
7.1.90.0080.00816.15
7.1.80.0070.00516.03
7.1.70.0070.00416.57
7.1.60.0070.01017.31
7.1.50.0090.00616.34
7.1.40.0030.01016.15
7.1.30.0050.00816.09
7.1.20.0060.00816.18
7.1.10.0040.00916.17
7.1.00.0050.01718.23
7.0.330.0100.00315.49
7.0.320.0050.00715.70
7.0.310.0030.00915.77
7.0.300.0020.01215.61
7.0.290.0020.01515.57
7.0.280.0070.00615.74
7.0.270.0050.00615.68
7.0.260.0040.00615.72
7.0.250.0070.00815.78
7.0.240.0030.00815.82
7.0.230.0040.00815.66
7.0.220.0040.00715.69
7.0.210.0070.00715.72
7.0.200.0280.00615.51
7.0.190.0070.00915.79
7.0.180.0050.00615.74
7.0.170.0050.00515.81
7.0.160.0090.00515.60
7.0.150.0060.00615.80
7.0.140.0050.02917.77
7.0.130.0060.00615.68
7.0.120.0100.00415.66
7.0.110.0090.00315.73
7.0.100.0040.00915.76
7.0.90.0060.00615.71
7.0.80.0070.00515.53
7.0.70.0030.01115.60
7.0.60.0080.02617.18
7.0.50.0030.01716.58
7.0.40.0090.03216.02
7.0.30.0110.02015.94
7.0.20.0090.02615.92
7.0.10.0130.03216.03
7.0.00.0050.03515.97
5.6.400.0050.01114.54
5.6.390.0030.01114.66
5.6.380.0100.00614.67
5.6.370.0040.01014.85
5.6.360.0100.00614.57
5.6.350.0040.00914.72
5.6.340.0020.00914.82
5.6.330.0070.00614.97
5.6.320.0050.00914.71
5.6.310.0030.00914.54
5.6.300.0060.00514.62
5.6.290.0110.00514.76
5.6.280.0040.02816.81
5.6.270.0030.01014.68
5.6.260.0090.00714.92
5.6.250.0060.00814.62
5.6.240.0070.00414.70
5.6.230.0060.00614.52
5.6.220.0020.01414.65
5.6.210.0070.01716.75
5.6.200.0080.01815.80
5.6.190.0040.03216.61
5.6.180.1320.02016.56
5.6.170.0140.03316.48
5.6.160.0050.02116.63
5.6.150.0120.02115.82
5.6.140.0070.01715.78
5.6.130.0090.02515.81
5.6.120.0090.03116.92
5.6.110.0060.01916.71
5.6.100.0060.02916.77
5.6.90.0060.02616.90
5.6.80.0060.02116.45
5.6.70.0120.03216.50
5.6.60.0020.00914.61
5.6.50.0100.00514.78
5.6.40.0080.00614.63
5.6.30.0070.00614.77
5.6.20.0020.00914.79
5.6.10.0050.01014.51
5.6.00.0030.00814.51
5.5.380.0080.00614.50
5.5.370.0070.00314.63
5.5.360.0030.01014.63
5.5.350.0080.03316.59
5.5.340.0100.03115.86
5.5.330.0070.02616.42
5.5.320.0110.01916.52
5.5.310.0120.01916.56
5.5.300.0040.03215.74
5.5.290.0060.02815.82
5.5.280.0040.01916.64
5.5.270.0050.03516.73
5.5.260.0060.03816.62
5.5.250.0020.03716.59
5.5.240.0060.01716.41
5.5.230.0040.00514.40
5.5.220.0060.00814.45
5.5.210.0090.00514.38
5.5.200.0080.00514.38
5.5.190.0050.00814.33
5.5.180.0040.00714.40
5.5.170.0040.00514.46
5.5.160.0040.00614.64
5.5.150.0030.01014.54
5.5.140.0030.00914.57
5.5.130.0070.00514.62
5.5.120.0060.00514.52
5.5.110.0030.01014.42
5.5.100.0070.00614.61
5.5.90.0020.00914.39
5.5.80.0050.00914.41
5.5.70.0030.00914.52
5.5.60.0050.00614.47
5.5.50.0060.00814.49
5.5.40.0060.00714.44
5.5.30.0060.00614.32
5.5.20.0050.00614.46
5.5.10.0030.00714.53
5.5.00.0070.00414.46
5.4.450.0320.02514.85
5.4.440.0270.02214.84
5.4.430.0340.02714.86
5.4.420.0320.02514.73
5.4.410.0040.02414.74
5.4.400.0480.02414.57
5.4.390.0520.02514.46
5.4.380.0110.02314.56
5.4.370.0080.02214.52
5.4.360.0060.02414.57
5.4.350.0070.02012.34
5.4.340.0080.02012.33
5.4.330.0040.00712.40
5.4.320.0040.01612.50
5.4.310.0050.01912.50
5.4.300.0040.01912.50
5.4.290.0050.01812.50
5.4.280.0050.01512.46
5.4.270.0020.02112.46
5.4.260.0050.01712.46
5.4.250.0040.02012.46
5.4.240.0040.02012.46
5.4.230.0050.02112.46
5.4.220.0050.01612.46
5.4.210.0080.01512.46
5.4.200.0060.02012.46
5.4.190.0090.02214.62
5.4.180.0020.03114.69
5.4.170.0060.02814.55
5.4.160.0090.01714.60
5.4.150.0090.02514.63
5.4.140.0040.02813.83
5.4.130.0070.02213.75
5.4.120.0050.02013.78
5.4.110.0040.02013.77
5.4.100.0070.01813.80
5.4.90.0080.01713.76
5.4.80.0090.02213.83
5.4.70.0070.02113.75
5.4.60.0070.02313.83
5.4.50.0030.02513.78
5.4.40.0100.02013.80
5.4.30.0060.02013.81
5.4.20.0100.02213.81
5.4.10.0070.02013.84
5.4.00.0070.02013.58
5.3.290.0070.01712.59
5.3.280.0060.01912.56
5.3.270.0100.02013.16
5.3.260.0050.02313.20
5.3.250.0070.03013.20
5.3.240.0070.02213.21
5.3.230.0090.01913.20
5.3.220.0050.02413.19
5.3.210.0090.02013.22
5.3.200.0080.01913.18
5.3.190.0040.02213.19
5.3.180.0080.02013.22
5.3.170.0080.02513.18
5.3.160.0100.02813.22
5.3.150.0070.02313.15
5.3.140.0090.02213.22
5.3.130.0050.02313.19
5.3.120.0130.01613.14
5.3.110.0070.02513.16
5.3.100.0100.01713.04
5.3.90.0060.02113.00
5.3.80.0070.02113.03
5.3.70.0040.02113.00
5.3.60.0080.02013.02
5.3.50.0070.01813.01
5.3.40.0060.02412.98
5.3.30.0160.01812.97
5.3.20.0050.02412.92
5.3.10.0060.02212.89
5.3.00.0070.02612.87
5.2.170.0030.04011.30
5.2.160.0030.04311.27
5.2.150.0100.05311.30
5.2.140.0070.05311.32
5.2.130.0130.04711.42
5.2.120.0130.03311.28
5.2.110.0070.03711.30
5.2.100.0030.04011.36
5.2.90.0070.04011.28
5.2.80.0130.03311.26
5.2.70.0070.04011.41
5.2.60.0070.04311.18
5.2.50.0130.03311.20
5.2.40.0070.05011.18
5.2.30.0030.04311.14
5.2.20.0130.04711.09
5.2.10.0030.04311.14
5.2.00.0100.05010.90
5.1.60.0070.03310.29
5.1.50.0000.05010.13
5.1.40.0070.03010.14
5.1.30.0130.03710.51
5.1.20.0000.06010.51
5.1.10.0000.04010.02
5.1.00.0070.0379.93
5.0.50.0030.0278.57
5.0.40.0030.0378.53
5.0.30.0030.0438.22
5.0.20.0030.0308.31
5.0.10.0070.0278.20
5.0.00.0070.0408.23
4.4.90.0000.0236.96
4.4.80.0000.0236.96
4.4.70.0030.0206.96
4.4.60.0000.0306.96
4.4.50.0030.0206.96
4.4.40.0130.0376.96
4.4.30.0100.0136.96
4.4.20.0030.0276.96
4.4.10.0070.0176.96
4.4.00.0030.0406.96
4.3.110.0000.0336.96
4.3.100.0030.0236.96
4.3.90.0100.0136.96
4.3.80.0000.0336.96
4.3.70.0070.0206.96
4.3.60.0030.0206.96
4.3.50.0030.0236.96
4.3.40.0100.0406.96
4.3.30.0000.0236.96
4.3.20.0030.0236.96
4.3.10.0070.0236.96
4.3.00.0170.0277.61

preferences:
54.34 ms | 401 KiB | 5 Q