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']);

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.01517.13
8.3.50.0160.00322.06
8.3.40.0070.01119.13
8.3.30.0140.00019.29
8.3.20.0000.00720.45
8.3.10.0050.00323.92
8.3.00.0030.00619.38
8.2.180.0040.01116.88
8.2.170.0090.01222.96
8.2.160.0130.00020.63
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0150.00326.16
8.2.120.0000.00922.50
8.2.110.0030.00619.65
8.2.100.0090.00318.15
8.2.90.0000.00919.41
8.2.80.0060.00317.97
8.2.70.0080.00017.88
8.2.60.0040.00418.30
8.2.50.0030.00618.10
8.2.40.0000.00818.37
8.2.30.0080.00018.29
8.2.20.0040.00418.05
8.2.10.0000.00818.32
8.2.00.0040.00818.05
8.1.280.0070.00725.92
8.1.270.0060.00324.14
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00321.05
8.1.230.0150.00018.20
8.1.220.0080.00017.91
8.1.210.0080.00018.77
8.1.200.0000.01117.73
8.1.190.0040.00417.60
8.1.180.0000.00818.10
8.1.170.0050.00318.77
8.1.160.0040.00422.31
8.1.150.0000.00818.88
8.1.140.0000.00817.75
8.1.130.0070.00018.12
8.1.120.0040.00417.61
8.1.110.0070.00017.64
8.1.100.0040.00417.74
8.1.90.0040.00417.80
8.1.80.0000.00917.66
8.1.70.0030.00517.74
8.1.60.0030.00617.77
8.1.50.0030.00517.66
8.1.40.0000.00817.70
8.1.30.0000.00817.95
8.1.20.0040.00417.98
8.1.10.0040.00417.89
8.1.00.0040.00417.87
8.0.300.0030.00718.77
8.0.290.0030.00916.88
8.0.280.0040.00418.61
8.0.270.0000.00717.59
8.0.260.0000.00617.58
8.0.250.0070.00017.31
8.0.240.0070.00017.16
8.0.230.0000.00717.14
8.0.220.0030.00317.09
8.0.210.0040.00417.25
8.0.200.0030.00317.20
8.0.190.0030.00617.27
8.0.180.0000.00717.21
8.0.170.0040.00417.20
8.0.160.0040.00417.20
8.0.150.0000.00717.09
8.0.140.0070.00017.09
8.0.130.0030.00313.57
8.0.120.0000.00717.02
8.0.110.0040.00417.07
8.0.100.0060.00317.14
8.0.90.0070.00017.04
8.0.80.0060.01017.13
8.0.70.0050.00217.20
8.0.60.0040.00417.20
8.0.50.0030.00517.07
8.0.30.0090.01317.30
8.0.20.0180.00717.49
8.0.10.0050.00317.41
8.0.00.0080.00917.22
7.4.330.0030.00315.00
7.4.320.0030.00316.90
7.4.300.0040.00416.90
7.4.290.0080.00016.83
7.4.280.0000.00716.85
7.4.270.0050.00316.95
7.4.260.0000.00716.86
7.4.250.0000.00716.81
7.4.240.0050.00216.87
7.4.230.0000.00816.92
7.4.220.0030.02117.00
7.4.210.0080.00916.83
7.4.200.0040.00416.96
7.4.190.0000.00716.68
7.4.160.0110.00516.63
7.4.150.0070.01117.40
7.4.140.0090.00817.86
7.4.130.0080.01016.78
7.4.120.0090.00916.74
7.4.110.0140.00316.82
7.4.100.0100.01016.76
7.4.90.0150.00616.94
7.4.80.0070.01619.39
7.4.70.0060.01216.91
7.4.60.0000.01616.71
7.4.50.0040.00416.93
7.4.40.0060.00622.77
7.4.30.0100.00716.78
7.4.10.0060.01215.02
7.4.00.0050.01215.08
7.3.330.0000.00613.61
7.3.320.0030.00313.54
7.3.310.0000.00716.54
7.3.300.0070.00016.51
7.3.290.0080.00816.64
7.3.280.0120.00816.67
7.3.270.0140.00417.40
7.3.260.0070.01016.84
7.3.250.0120.00916.73
7.3.240.0120.00416.66
7.3.230.0160.00016.63
7.3.210.0170.00316.71
7.3.200.0120.00919.39
7.3.190.0110.01116.80
7.3.180.0110.00616.80
7.3.170.0060.00916.94
7.3.160.0140.00616.73
7.3.130.0060.01315.13
7.3.120.0090.00914.92
7.3.110.0090.00915.00
7.3.100.0070.00714.98
7.3.90.0030.01415.24
7.3.80.0090.00914.98
7.3.70.0070.00715.14
7.3.60.0080.00614.98
7.3.50.0040.01114.91
7.3.40.0070.00714.89
7.3.30.0080.00814.88
7.3.20.0030.01316.93
7.3.10.0060.01216.89
7.3.00.0000.01416.87
7.2.330.0070.01116.64
7.2.320.0120.01216.96
7.2.310.0060.01116.98
7.2.300.0120.00617.05
7.2.290.0090.01217.01
7.2.260.0090.00915.02
7.2.250.0070.01315.55
7.2.240.0030.01015.27
7.2.230.0000.01415.44
7.2.220.0060.01315.23
7.2.210.0070.01115.28
7.2.200.0000.01415.25
7.2.190.0030.01415.25
7.2.180.0030.00615.24
7.2.170.0030.00715.26
7.2.160.0070.00715.28
7.2.150.0120.00317.18
7.2.140.0090.00917.08
7.2.130.0120.00617.06
7.2.120.0080.00817.14
7.2.110.0090.00316.90
7.2.100.0000.01617.17
7.2.90.0060.00617.18
7.2.80.0030.00916.84
7.2.70.0030.01216.95
7.2.60.0110.00417.24
7.2.50.0060.00917.32
7.2.40.0080.00317.19
7.2.30.0090.00316.99
7.2.20.0070.00716.97
7.2.10.0030.01416.98
7.2.00.0130.00317.02
7.1.330.0040.00715.83
7.1.320.0060.01215.80
7.1.310.0030.01016.00
7.1.300.0040.01116.07
7.1.290.0000.01315.74
7.1.280.0070.00715.93
7.1.270.0110.00315.86
7.1.260.0000.01515.80
7.1.250.0040.01116.25
7.1.240.0030.00916.04
7.1.230.0060.00615.85
7.1.220.0100.00316.07
7.1.210.0000.00916.05
7.1.200.0060.00716.04
7.1.190.0040.01416.02
7.1.180.0090.00615.92
7.1.170.0090.00315.95
7.1.160.0040.00815.93
7.1.150.0090.00615.86
7.1.140.0000.01315.89
7.1.130.0060.00615.87
7.1.120.0030.00615.99
7.1.110.0120.00316.07
7.1.100.0080.00516.28
7.1.90.0000.01315.81
7.1.80.0040.01215.76
7.1.70.0040.00516.57
7.1.60.0090.01017.65
7.1.50.0050.00916.57
7.1.40.0080.00616.01
7.1.30.0060.00916.07
7.1.20.0030.01315.85
7.1.10.0030.01316.11
7.1.00.0020.04419.34
7.0.330.0120.00615.33
7.0.320.0090.00315.60
7.0.310.0100.00715.36
7.0.300.0120.00015.54
7.0.290.0040.01115.48
7.0.280.0070.00315.36
7.0.270.0040.01115.55
7.0.260.0040.01115.62
7.0.250.0030.01215.63
7.0.240.0070.00615.72
7.0.230.0000.01215.59
7.0.220.0060.01015.66
7.0.210.0000.01415.70
7.0.200.0100.00116.29
7.0.190.0100.00715.63
7.0.180.0000.00915.65
7.0.170.0000.01315.61
7.0.160.0000.01115.55
7.0.150.0090.00315.67
7.0.140.0050.04018.85
7.0.130.0060.00615.63
7.0.120.0040.01115.61
7.0.110.0060.00315.54
7.0.100.0040.00815.64
7.0.90.0030.01015.67
7.0.80.0060.00615.49
7.0.70.0030.01015.62
7.0.60.0080.04417.85
7.0.50.0090.04216.93
7.0.40.0070.04716.96
7.0.30.0180.04317.01
7.0.20.0110.02916.86
7.0.10.0060.04616.95
7.0.00.0150.04016.99
5.6.400.0070.00714.57
5.6.390.0090.00914.48
5.6.380.0080.00614.44
5.6.370.0060.01214.50
5.6.360.0080.00314.54
5.6.350.0060.01214.48
5.6.340.0070.00314.56
5.6.330.0000.01014.49
5.6.320.0060.00914.58
5.6.310.0030.01314.66
5.6.300.0080.00414.64
5.6.290.0060.00614.70
5.6.280.0030.01014.51
5.6.270.0060.00314.38
5.6.260.0040.00714.52
5.6.250.0110.00414.55
5.6.240.0030.01014.52
5.6.230.0000.01514.66
5.6.220.0060.01214.61
5.6.210.0030.04617.60
5.6.200.0100.03516.49
5.6.190.0060.04617.58
5.6.180.0220.04017.53
5.6.170.0120.03617.58
5.6.160.0060.04817.50
5.6.150.0080.04516.58
5.6.140.0050.02716.42
5.6.130.0070.02216.46
5.6.120.0060.04117.81
5.6.110.0110.03617.87
5.6.100.0110.03617.85
5.6.90.0070.04718.05
5.6.80.0110.02917.55
5.6.70.2220.02917.46
5.6.60.0100.00614.48
5.6.50.0000.01214.54
5.6.40.0060.00914.53
5.6.30.0090.00014.72
5.6.20.0030.01014.40
5.6.10.0060.00314.48
5.6.00.0000.01614.38
5.5.380.0030.00714.53
5.5.370.0130.00014.41
5.5.360.0060.00914.45
5.5.350.0090.02617.41
5.5.340.0080.02016.37
5.5.330.0090.02217.53
5.5.320.0220.02217.39
5.5.310.0150.04517.45
5.5.300.0080.04416.52
5.5.290.0020.05116.38
5.5.280.0100.03317.70
5.5.270.0100.02217.59
5.5.260.0050.02317.61
5.5.250.0020.02717.49
5.5.240.0090.04417.53
5.5.230.0110.00014.54
5.5.220.0070.00714.60
5.5.210.0000.01314.59
5.5.200.0120.00314.59
5.5.190.0040.00714.17
5.5.180.0070.00314.60
5.5.170.0090.00614.62
5.5.160.0000.01514.43
5.5.150.0030.00614.40
5.5.140.0000.01514.17
5.5.130.0100.00714.80
5.5.120.0080.00314.42
5.5.110.0080.00314.62
5.5.100.0040.01114.41
5.5.90.0030.00714.36
5.5.80.0030.01014.34
5.5.70.0040.01114.41
5.5.60.0100.00314.46
5.5.50.0060.01214.55
5.5.40.0100.00314.25
5.5.30.0090.00314.17
5.5.20.0040.00414.31
5.5.10.0000.01314.57
5.5.00.0070.00714.25
5.4.450.0050.03716.42
5.4.440.0080.03216.32
5.4.430.0380.03316.29
5.4.420.0400.03716.28
5.4.410.0180.04516.29
5.4.400.0260.03816.17
5.4.390.0400.02516.16
5.4.380.0100.03015.97
5.4.370.0080.03515.82
5.4.360.0100.03016.00
5.4.350.0110.03015.99
5.4.340.0100.02815.88
5.4.330.0060.00613.08
5.4.320.0060.02312.89
5.4.310.0050.02512.89
5.4.300.0070.02312.89
5.4.290.0080.03612.89
5.4.280.0060.02212.84
5.4.270.0060.02112.83
5.4.260.0040.02612.84
5.4.250.0060.02412.83
5.4.240.0040.02612.84
5.4.230.0070.01912.83
5.4.220.0060.02312.83
5.4.210.0040.02612.83
5.4.200.0080.01912.83
5.4.190.0070.02812.83
5.4.180.0130.02412.83
5.4.170.0070.02712.83
5.4.160.0120.02412.83
5.4.150.0110.02412.83
5.4.140.0110.02212.67
5.4.130.0150.02112.66
5.4.120.0070.02912.64
5.4.110.0060.03012.64
5.4.100.0120.02512.64
5.4.90.0110.02412.64
5.4.80.0090.02612.64
5.4.70.0100.02612.64
5.4.60.0090.02512.64
5.4.50.0100.02312.64
5.4.40.0140.02212.64
5.4.30.0130.02412.63
5.4.20.0180.04812.63
5.4.10.0080.02612.63
5.4.00.0100.02312.38
5.3.290.0040.03013.02
5.3.280.0100.02512.99
5.3.270.0140.02112.98
5.3.260.0120.02312.98
5.3.250.0120.02212.98
5.3.240.0070.03012.98
5.3.230.0100.02812.98
5.3.220.0090.02712.96
5.3.210.0070.02812.96
5.3.200.0110.02612.96
5.3.190.0120.02412.96
5.3.180.0090.02712.96
5.3.170.0100.02412.96
5.3.160.0080.02912.96
5.3.150.0110.02612.96
5.3.140.0070.03012.96
5.3.130.0070.02812.96
5.3.120.0130.02312.96
5.3.110.0110.02712.96
5.3.100.0100.02412.70
5.3.90.0110.02512.69
5.3.80.0110.02512.69
5.3.70.0110.02612.68
5.3.60.0090.02712.68
5.3.50.0090.02712.65
5.3.40.0100.02412.65
5.3.30.0140.02412.63
5.3.20.0120.02412.52
5.3.10.0100.02512.51
5.3.00.0110.02412.50
5.2.170.0180.0339.42
5.2.160.0160.0319.42
5.2.150.0100.0399.42
5.2.140.0130.0369.42
5.2.130.0090.0389.38
5.2.120.0180.0299.38
5.2.110.0130.0369.38
5.2.100.0110.0369.38
5.2.90.0110.0379.38
5.2.80.0150.0339.37
5.2.70.0110.0389.37
5.2.60.0090.0399.32
5.2.50.0120.0369.30
5.2.40.0100.0389.27
5.2.30.0120.0359.25
5.2.20.0130.0349.23
5.2.10.0110.0369.14
5.2.00.0120.0348.99
5.1.60.0120.0298.27
5.1.50.0110.0308.27
5.1.40.0130.0288.25
5.1.30.0110.0328.61
5.1.20.0100.0338.59
5.1.10.0060.0378.17
5.1.00.0140.0288.17
5.0.50.0080.0266.66
5.0.40.0130.0206.51
5.0.30.0090.0366.33
5.0.20.0080.0266.30
5.0.10.0080.0246.27
5.0.00.0080.0366.26
4.4.90.0060.0204.77
4.4.80.0060.0204.76
4.4.70.0080.0184.75
4.4.60.0060.0204.75
4.4.50.0090.0174.77
4.4.40.0080.0274.71
4.4.30.0060.0204.76
4.4.20.0080.0174.84
4.4.10.0120.0144.85
4.4.00.0110.0254.76
4.3.110.0040.0214.67
4.3.100.0100.0154.66
4.3.90.0080.0174.64
4.3.80.0090.0264.58
4.3.70.0090.0154.63
4.3.60.0110.0144.63
4.3.50.0080.0174.63
4.3.40.0070.0274.54
4.3.30.0060.0183.30
4.3.20.0050.0193.27
4.3.10.0060.0173.24
4.3.00.0000.0237.78

preferences:
43.52 ms | 401 KiB | 5 Q