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 (is_int($offset)) { $tag = $this->xml->getName(); $parent = $this->xml->xpath('../'); $parent = $parent[0]; $target = $parent->xpath($tag . '[' . $offset . ']'); $target = $target[0]; return new self($target->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']; var_dump($xml['note']['recursive']['val'][0]);

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.0190.00018.83
8.3.50.0110.00622.35
8.3.40.0090.00619.52
8.3.30.0090.00619.45
8.3.20.0080.00021.10
8.3.10.0040.00422.65
8.3.00.0000.00822.88
8.2.180.0130.01017.25
8.2.170.0150.00722.96
8.2.160.0070.00721.44
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00926.16
8.2.120.0060.00319.86
8.2.110.0070.00319.67
8.2.100.0060.00618.19
8.2.90.0040.00419.47
8.2.80.0050.00318.30
8.2.70.0000.00917.85
8.2.60.0000.00818.41
8.2.50.0000.00818.07
8.2.40.0050.00318.55
8.2.30.0040.00418.43
8.2.20.0030.00518.27
8.2.10.0000.00919.90
8.2.00.0040.00418.09
8.1.280.0160.00625.92
8.1.270.0040.00424.20
8.1.260.0080.00026.35
8.1.250.0100.01028.09
8.1.240.0000.01022.51
8.1.230.0080.00421.48
8.1.220.0030.00518.14
8.1.210.0050.00318.77
8.1.200.0030.00617.85
8.1.190.0000.00818.03
8.1.180.0070.00418.10
8.1.170.0060.00318.92
8.1.160.0000.00722.34
8.1.150.0000.00819.02
8.1.140.0040.00417.97
8.1.130.0000.00718.17
8.1.120.0000.00717.91
8.1.110.0050.00217.91
8.1.100.0040.00417.89
8.1.90.0040.00417.93
8.1.80.0000.00917.88
8.1.70.0040.00417.76
8.1.60.0090.00018.06
8.1.50.0000.00817.88
8.1.40.0000.00817.79
8.1.30.0050.00518.07
8.1.20.0050.00318.14
8.1.10.0090.00017.85
8.1.00.0030.00617.98
8.0.300.0070.00018.77
8.0.290.0000.00717.68
8.0.280.0000.00718.81
8.0.270.0050.00217.61
8.0.260.0030.00317.18
8.0.250.0000.00717.31
8.0.240.0000.00717.40
8.0.230.0050.00217.45
8.0.220.0040.00417.22
8.0.210.0000.00717.34
8.0.200.0000.00717.32
8.0.190.0050.00317.45
8.0.180.0020.00517.44
8.0.170.0030.00517.44
8.0.160.0000.00717.29
8.0.150.0040.00417.38
8.0.140.0040.00417.36
8.0.130.0000.00613.79
8.0.120.0030.00617.18
8.0.110.0000.00817.41
8.0.100.0070.00317.35
8.0.90.0000.00717.35
8.0.80.0070.01117.39
8.0.70.0040.00417.53
8.0.60.0030.00517.31
8.0.50.0040.00417.25
8.0.30.0100.01017.68
8.0.20.0100.00817.69
8.0.10.0000.00817.50
8.0.00.0100.01017.32
7.4.330.0000.00515.46
7.4.320.0000.00616.83
7.4.300.0000.00716.86
7.4.290.0060.00316.91
7.4.280.0030.00316.75
7.4.270.0030.00616.86
7.4.260.0000.00716.90
7.4.250.0040.00416.63
7.4.240.0000.00816.87
7.4.230.0040.00417.01
7.4.220.0060.00916.84
7.4.210.0060.01416.96
7.4.200.0000.00716.90
7.4.190.0000.00716.69
7.4.160.0080.01316.80
7.4.150.0110.00717.40
7.4.140.0080.01317.86
7.4.130.0100.01016.77
7.4.120.0090.00916.85
7.4.110.0130.01317.03
7.4.100.0080.00816.76
7.4.90.0230.00016.77
7.4.80.0080.00819.39
7.4.70.0090.01216.90
7.4.60.0090.00616.86
7.4.50.0000.00416.84
7.4.40.0040.01422.77
7.4.30.0120.00616.91
7.4.00.0030.01315.10
7.3.330.0050.00013.44
7.3.320.0000.00813.61
7.3.310.0070.00016.67
7.3.300.0070.00016.65
7.3.290.0060.00916.61
7.3.280.0090.01116.63
7.3.270.0110.00617.40
7.3.260.0150.01016.88
7.3.250.0080.01116.91
7.3.240.0140.00416.93
7.3.230.0060.01516.93
7.3.210.0110.00816.76
7.3.200.0060.01319.39
7.3.190.0090.00916.70
7.3.180.0120.00316.94
7.3.170.0130.00316.87
7.3.160.0070.01116.67
7.3.120.0110.00415.16
7.3.10.0110.01016.56
7.3.00.0110.00716.57
7.2.330.0060.01217.09
7.2.320.0180.00717.00
7.2.310.0090.00917.16
7.2.300.0140.00616.91
7.2.290.0060.01216.87
7.2.130.0120.00717.00
7.2.120.0140.00616.91
7.2.110.0120.00716.90
7.2.100.0100.00916.87
7.2.90.0130.00716.97
7.2.80.0110.00616.88
7.2.70.0110.00816.96
7.2.60.0060.00917.00
7.2.50.0160.00717.07
7.2.40.0160.00717.12
7.2.30.0130.00716.97
7.2.20.0170.00417.04
7.2.10.0060.01116.97
7.2.00.0090.00717.46
7.1.250.0090.00915.79
7.1.240.0190.00615.80
7.1.230.0150.00815.91
7.1.220.0150.00215.77
7.1.210.0040.00915.87
7.1.200.0100.01016.02
7.1.190.0210.00415.87
7.1.180.0110.00915.79
7.1.170.0160.00615.96
7.1.160.0070.01016.01
7.1.150.0160.00715.92
7.1.140.0110.00616.01
7.1.130.0150.00816.02
7.1.120.0190.00315.91
7.1.110.0160.00815.93
7.1.100.0090.00816.78
7.1.90.0150.00315.98
7.1.80.0140.00816.02
7.1.70.0120.00516.43
7.1.60.0120.00817.20
7.1.50.0220.00616.26
7.1.40.0100.00815.78
7.1.30.0080.00915.85
7.1.20.0190.00215.92
7.1.10.0090.00916.02
7.1.00.0170.02918.10
7.0.330.0110.00815.58
7.0.320.0160.00815.54
7.0.310.0100.00515.39
7.0.300.0060.00815.49
7.0.290.0160.00415.44
7.0.280.0100.00815.47
7.0.270.0120.00715.58
7.0.260.0110.00715.50
7.0.250.0130.00415.60
7.0.240.0140.00715.48
7.0.230.0320.00615.58
7.0.220.0070.00515.56
7.0.210.0110.00615.57
7.0.200.0120.00415.96
7.0.190.0150.00515.43
7.0.180.0160.00515.53
7.0.170.0200.00515.54
7.0.160.0100.00615.61
7.0.150.0120.00715.47
7.0.140.0070.03017.79
7.0.130.0130.00515.51
7.0.120.0180.00915.53
7.0.110.0200.01317.02
7.0.100.0120.02317.10
7.0.90.0190.02417.01
7.0.80.0270.03417.04
7.0.70.0270.02816.97
7.0.60.0340.03117.04
7.0.50.0400.03117.33
7.0.40.0100.02215.89
7.0.30.0050.02315.66
7.0.20.0100.02915.60
7.0.10.0090.02915.79
7.0.00.0090.02815.73
5.6.380.0130.00514.37
5.6.370.0110.00314.58
5.6.360.0110.00214.45
5.6.350.0020.01214.69
5.6.340.0100.00614.67
5.6.330.0140.00214.60
5.6.320.0080.00714.60
5.6.310.0070.00714.55
5.6.300.0100.00614.45
5.6.290.0050.01014.54
5.6.280.0060.03016.58
5.6.270.0140.00214.62
5.6.260.0000.01314.47
5.6.250.0090.02616.37
5.6.240.0050.02316.61
5.6.230.0050.02616.45
5.6.220.0090.03216.57
5.6.210.0070.03016.54
5.6.200.0090.03216.70
5.6.190.0100.02416.68
5.6.180.0120.02716.72
5.6.170.0100.03116.63
5.6.160.0060.03316.79
5.6.150.0130.02716.66
5.6.140.0090.02816.91
5.6.130.0040.03316.81
5.6.120.0050.03116.61
5.6.110.0090.03116.86
5.6.100.0070.01916.83
5.6.90.0110.03216.51
5.6.80.0070.02516.46
5.6.70.0090.02916.39
5.6.60.0100.02816.31
5.6.50.0100.03116.58
5.6.40.0110.01916.62
5.6.30.0090.03016.56
5.6.20.0080.03016.56
5.6.10.0070.03216.34
5.6.00.0090.02916.38
5.5.380.0060.01614.45
5.5.370.0060.02114.46
5.5.360.0100.02814.39
5.5.350.0070.03314.50
5.5.340.0110.02514.72
5.5.330.0060.02914.49
5.5.320.0030.03414.66
5.5.310.0070.02714.53
5.5.300.0080.01814.68
5.5.290.0040.02914.69
5.5.280.0080.03114.57
5.5.270.0110.02714.57
5.5.260.0080.02814.66
5.5.250.0080.03114.51
5.5.240.0050.03114.38
5.5.230.0100.02314.37
5.5.220.0090.02714.40
5.5.210.0050.03114.47
5.5.200.0080.03014.34
5.5.190.0070.03014.36
5.5.180.0090.02414.39
5.5.170.0060.00712.84
5.5.160.0100.01514.34
5.5.150.0040.03214.42
5.5.140.0070.02914.33
5.5.130.0060.02914.38
5.5.120.0060.03014.35
5.5.110.0050.03114.38
5.5.100.0100.02614.39
5.5.90.0060.02914.38
5.5.80.0050.03014.25
5.5.70.0110.02614.31
5.5.60.0100.02614.36
5.5.50.0080.02914.23
5.5.40.0120.02714.30
5.5.30.0080.01714.34
5.5.20.0090.02914.35
5.5.10.0080.02814.25
5.5.00.0040.02014.33
5.4.450.0050.02114.02
5.4.440.0080.02914.07
5.4.430.0060.02914.18
5.4.420.0060.02114.06
5.4.410.0050.03014.04
5.4.400.0050.03013.97
5.4.390.0050.02913.96
5.4.380.0060.03013.91
5.4.370.0090.02614.01
5.4.360.0090.02613.90
5.4.350.0060.03113.96
5.4.340.0100.02413.91
5.4.330.0060.00711.38
5.4.320.0100.02713.93
5.4.310.0080.02914.04
5.4.300.0090.02813.96
5.4.290.0130.02413.90
5.4.280.0080.02813.97
5.4.270.0100.02813.96
5.4.260.0140.02414.06
5.4.250.0110.02514.04
5.4.240.0070.02913.98
5.4.230.0060.02913.93
5.4.220.0080.02714.06
5.4.210.0110.02713.98
5.4.200.0110.01514.01
5.4.190.0040.03114.05
5.4.180.0060.03014.02
5.4.170.0120.02814.09
5.4.160.0080.01814.11
5.4.150.0100.02013.98
5.4.140.0120.02513.21
5.4.130.0070.01613.15
5.4.120.0040.03113.14
5.4.110.0100.02613.19
5.4.100.0060.02913.20
5.4.90.0090.02613.13
5.4.80.0060.02713.03
5.4.70.0080.02113.01
5.4.60.0040.03113.08
5.4.50.0050.02713.09
5.4.40.0070.02813.10
5.4.30.0030.03113.18
5.4.20.0030.02913.03
5.4.10.0090.02613.13
5.4.00.0070.02812.96
5.3.290.0080.02612.52
5.3.280.0100.02512.45
5.3.270.0060.03212.45
5.3.260.0080.02712.45
5.3.250.0090.02512.52
5.3.240.0040.02912.50
5.3.230.0050.01512.45
5.3.220.0050.02912.46
5.3.210.0060.03012.47
5.3.200.0080.02712.47
5.3.190.0050.02812.44
5.3.180.0060.02712.48
5.3.170.0090.02712.45
5.3.160.0100.02512.44
5.3.150.0090.02312.47
5.3.140.0090.02512.46
5.3.130.0120.02112.44
5.3.120.0090.02612.44
5.3.110.0030.02212.48
5.3.100.0070.02612.29
5.3.90.0080.01612.28
5.3.80.0060.02612.28
5.3.70.0080.02312.28
5.3.60.0050.02912.29
5.3.50.0070.02412.31
5.3.40.0080.02412.22
5.3.30.0050.01512.23
5.3.20.0050.02912.18
5.3.10.0080.01512.16
5.3.00.0060.02712.16
5.2.170.0030.02511.31
5.2.160.0070.02211.30
5.2.150.0080.02111.34
5.2.140.0050.02511.33
5.2.130.0010.01811.32
5.2.120.0060.02111.29
5.2.110.0080.02011.31
5.2.100.0070.02211.36
5.2.90.0060.02411.31
5.2.80.0050.02211.30
5.2.70.0070.02211.29
5.2.60.0040.02411.27
5.2.50.0040.02511.26
5.2.40.0030.02511.24
5.2.30.0070.02311.28
5.2.20.0070.02111.27
5.2.10.0040.01511.23
5.2.00.0040.01411.16
5.1.60.0060.00910.90
5.1.50.0040.01910.90
5.1.40.0050.01910.90
5.1.30.0050.02111.05
5.1.20.0070.01911.07
5.1.10.0060.01710.94
5.1.00.0030.01610.94
5.0.50.0040.01710.40
5.0.40.0030.01810.36
5.0.30.0030.02710.32
5.0.20.0050.01410.30
5.0.10.0020.01810.31
5.0.00.0050.02010.34
4.4.90.0050.01210.30
4.4.80.0030.01310.30
4.4.70.0040.01310.30
4.4.60.0010.01710.30
4.4.50.0020.01510.30
4.4.40.0010.02110.30
4.4.30.0020.01410.30
4.4.20.0020.01610.30
4.4.10.0020.01310.30
4.4.00.0010.01310.30
4.3.110.0010.01510.30
4.3.100.0030.01310.30
4.3.90.0030.01410.30
4.3.80.0020.02110.30
4.3.70.0020.01310.30
4.3.60.0050.01210.30
4.3.50.0010.01510.30
4.3.40.0030.02010.30
4.3.30.0030.01010.30
4.3.20.0020.00910.30
4.3.10.0020.01410.30
4.3.00.0010.01410.30

preferences:
43.83 ms | 401 KiB | 5 Q