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(); $target = $this->xml->xpath('../' . $tag); $target = $target[$offset]; 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']; $test = $xml['note']['recursive']['val']; var_dump((array) $test); echo $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.0100.01018.80
8.3.50.0140.00522.25
8.3.40.0060.00919.11
8.3.30.0120.00319.46
8.3.20.0040.00420.50
8.3.10.0050.00322.05
8.3.00.0080.00020.94
8.2.180.0040.01116.63
8.2.170.0040.01122.96
8.2.160.0000.01419.71
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0060.01226.16
8.2.120.0080.00019.61
8.2.110.0030.00722.50
8.2.100.0060.00619.95
8.2.90.0000.00819.39
8.2.80.0080.00018.43
8.2.70.0000.00818.00
8.2.60.0030.00618.30
8.2.50.0050.00318.07
8.2.40.0060.00318.53
8.2.30.0080.00018.43
8.2.20.0080.00018.05
8.2.10.0040.00417.98
8.2.00.0050.00318.02
8.1.280.0170.00325.92
8.1.270.0080.00022.39
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0040.00423.92
8.1.230.0070.00419.35
8.1.220.0060.00318.16
8.1.210.0000.00918.77
8.1.200.0040.00417.60
8.1.190.0080.00017.80
8.1.180.0080.00018.95
8.1.170.0060.00319.03
8.1.160.0040.00422.43
8.1.150.0000.00818.84
8.1.140.0030.00917.73
8.1.130.0030.00318.14
8.1.120.0000.00717.80
8.1.110.0030.00517.70
8.1.100.0040.00417.68
8.1.90.0000.00817.80
8.1.80.0050.00217.75
8.1.70.0000.00717.73
8.1.60.0050.00517.83
8.1.50.0040.00417.85
8.1.40.0040.00417.73
8.1.30.0050.00218.00
8.1.20.0000.00817.83
8.1.10.0080.00017.95
8.1.00.0030.00517.81
8.0.300.0050.00218.77
8.0.290.0080.00017.30
8.0.280.0030.00318.75
8.0.270.0030.00317.68
8.0.260.0000.00717.14
8.0.250.0000.00717.25
8.0.240.0000.00817.29
8.0.230.0070.00017.31
8.0.220.0000.00717.25
8.0.210.0000.00717.16
8.0.200.0050.00317.23
8.0.190.0060.00317.33
8.0.180.0040.00317.23
8.0.170.0000.00817.11
8.0.160.0040.00417.20
8.0.150.0000.00917.17
8.0.140.0040.00417.18
8.0.130.0000.00613.66
8.0.120.0060.00317.08
8.0.110.0030.00617.10
8.0.100.0000.00817.26
8.0.90.0030.00517.03
8.0.80.0100.00617.24
8.0.70.0000.00817.01
8.0.60.0040.00417.08
8.0.50.0080.00017.06
8.0.30.0120.00717.42
8.0.20.0080.01017.40
8.0.10.0000.00817.36
8.0.00.0140.00517.05
7.4.330.0060.00015.00
7.4.320.0030.00316.96
7.4.300.0000.00716.83
7.4.290.0000.00716.92
7.4.280.0030.00316.88
7.4.270.0050.00216.95
7.4.260.0040.00416.79
7.4.250.0000.00716.93
7.4.240.0050.00216.89
7.4.230.0030.00316.90
7.4.220.0120.00616.86
7.4.210.0080.00916.94
7.4.200.0050.00216.92
7.4.190.0000.00716.80
7.4.160.0060.01016.77
7.4.150.0170.00017.40
7.4.140.0150.00417.86
7.4.130.0110.00716.80
7.4.120.0090.00816.91
7.4.110.0100.00717.02
7.4.100.0030.01416.74
7.4.90.0110.00816.86
7.4.80.0100.01019.39
7.4.70.0110.01416.57
7.4.60.0140.00416.84
7.4.50.0030.00316.82
7.4.40.0030.01022.77
7.4.30.0070.01116.67
7.4.00.0060.01015.12
7.3.330.0050.00013.63
7.3.320.0030.00313.46
7.3.310.0040.00416.71
7.3.300.0000.00716.70
7.3.290.0030.01216.66
7.3.280.0060.01016.62
7.3.270.0110.00617.40
7.3.260.0090.00916.71
7.3.250.0080.01116.83
7.3.240.0070.01016.95
7.3.230.0130.00916.66
7.3.210.0200.00316.62
7.3.200.0150.00319.39
7.3.190.0090.00916.74
7.3.180.0090.00816.66
7.3.170.0060.01016.70
7.3.160.0060.01016.71
7.3.120.0090.00714.85
7.3.110.0040.01414.90
7.3.100.0030.01214.94
7.3.90.0060.00914.76
7.3.80.0060.00914.95
7.3.70.0090.00915.17
7.3.60.0110.00315.01
7.3.50.0040.01115.09
7.3.40.0000.01314.89
7.3.30.0070.00715.08
7.3.20.0000.01416.92
7.3.10.0080.00716.70
7.3.00.0050.00716.71
7.2.330.0030.01517.15
7.2.320.0100.01017.05
7.2.310.0090.00917.09
7.2.300.0030.01417.05
7.2.290.0100.00716.84
7.2.250.0070.01015.12
7.2.240.0030.01815.36
7.2.230.0030.01415.43
7.2.220.0030.01015.38
7.2.210.0070.01115.13
7.2.200.0070.01015.28
7.2.190.0060.01215.09
7.2.180.0000.01915.34
7.2.170.0120.00615.27
7.2.130.0030.01017.13
7.2.120.0100.00317.02
7.2.110.0100.00717.26
7.2.100.0040.00917.14
7.2.90.0100.00617.20
7.2.80.0140.00017.25
7.2.70.0030.01017.07
7.2.60.0030.01317.22
7.2.50.0030.01017.37
7.2.40.0000.01417.11
7.2.30.0060.00617.08
7.2.20.0090.00417.14
7.2.10.0000.01317.15
7.2.00.0030.00916.86
7.1.330.0040.01116.23
7.1.320.0040.01115.77
7.1.310.0110.00415.93
7.1.300.0080.00815.84
7.1.290.0090.00616.10
7.1.280.0060.00915.84
7.1.270.0060.00915.93
7.1.260.0070.00316.12
7.1.250.0040.01115.96
7.1.100.0000.01318.33
7.1.70.0000.00917.14
7.1.60.0060.01919.82
7.1.50.0070.01516.91
7.1.00.0000.07722.50
7.0.200.0110.00716.95
7.0.140.0070.07322.18
7.0.60.0070.09020.13
7.0.50.0070.08017.95
7.0.40.0030.04320.46
7.0.30.0170.05720.32
7.0.20.0200.03720.30
7.0.10.0430.06720.32
7.0.00.0070.09020.24
5.6.280.0070.07021.19
5.6.210.0070.04720.75
5.6.200.0070.04318.25
5.6.190.0030.04720.80
5.6.180.3430.03720.83
5.6.170.0170.04320.70
5.6.160.0130.04720.71
5.6.150.0100.04018.22
5.6.140.0100.04318.33
5.6.130.0070.06718.21
5.6.120.0100.04321.08
5.6.110.0030.08021.26
5.6.100.0100.08021.19
5.6.90.0130.05321.06
5.6.80.0000.04320.55
5.6.70.0370.07320.59
5.5.350.0030.08020.52
5.5.340.0070.08018.01
5.5.330.0070.08320.42
5.5.320.0130.05020.42
5.5.310.0230.04320.43
5.5.300.0000.06018.02
5.5.290.0130.08018.16
5.5.280.0070.05720.95
5.5.270.0070.05320.95
5.5.260.0070.08720.86
5.5.250.0130.07720.77
5.5.240.0000.08720.27
5.4.450.0430.06319.68
5.4.440.0570.05719.58
5.4.430.0770.05019.43
5.4.420.0570.05719.56
5.4.410.0170.05019.41
5.4.400.0770.00019.01
5.4.390.0770.00018.95
5.4.380.0230.05718.80
5.4.370.0400.05718.91
5.4.360.0300.05018.78
5.4.350.0330.04718.58
5.4.340.0300.04718.83
5.4.320.0050.03712.71
5.4.310.0090.03412.70
5.4.300.0060.04812.71
5.4.290.0090.04112.70
5.4.280.0070.03612.59
5.4.270.0040.04312.60
5.4.260.0090.03312.60
5.4.250.0070.04212.59
5.4.240.0070.04412.60
5.4.230.0060.04212.59
5.4.220.0060.03912.59
5.4.210.0070.04412.59
5.4.200.0060.03912.58
5.4.190.0100.06318.78
5.4.180.0230.06718.97
5.4.170.0200.06018.87
5.4.160.0070.05719.14
5.4.150.0030.08319.12
5.4.140.0000.08316.81
5.4.130.0070.05016.77
5.4.120.0130.04716.55
5.4.110.0000.05716.72
5.4.100.0070.05716.61
5.4.90.0170.04716.74
5.4.80.0130.04316.75
5.4.70.0070.05316.73
5.4.60.0030.07716.48
5.4.50.0100.06316.46
5.4.40.0100.06716.48
5.4.30.0070.05016.57
5.4.20.0170.04716.61
5.4.10.0130.07016.46
5.4.00.0230.05315.98
5.3.290.0100.04012.97
5.3.280.0050.03812.89
5.3.270.0100.06314.90
5.3.260.0070.05714.92
5.3.250.0100.06314.80
5.3.240.0100.06314.83
5.3.230.0100.04714.67
5.3.220.0100.05014.71
5.3.210.0100.05014.70
5.3.200.0070.05714.79
5.3.190.0070.07714.71
5.3.180.0070.05714.80
5.3.170.0000.07714.75
5.3.160.0200.04014.71
5.3.150.0100.05714.76
5.3.140.0200.04314.87
5.3.130.0100.05314.74
5.3.120.0100.05714.77
5.3.110.0200.04314.82
5.3.100.0000.07714.18
5.3.90.0030.05314.21
5.3.80.0070.05314.30
5.3.70.0030.05714.25
5.3.60.0130.06714.30
5.3.50.0170.06314.01
5.3.40.0130.05014.18
5.3.30.0130.06314.18
5.3.20.0130.05713.77
5.3.10.0100.05013.75
5.3.00.0170.04713.83
5.2.170.0100.04011.36
5.2.160.0070.06311.24
5.2.150.0130.03711.29
5.2.140.0030.05011.38
5.2.130.0070.04011.16
5.2.120.0070.04011.29
5.2.110.0100.04711.37
5.2.100.0100.05711.28
5.2.90.0100.03711.30
5.2.80.0000.05011.28
5.2.70.0130.03711.28
5.2.60.0070.06011.18
5.2.50.0030.04711.11
5.2.40.0070.04311.18
5.2.30.0100.03711.16
5.2.20.0200.03711.29
5.2.10.0030.04711.10
5.2.00.0070.05311.00
5.1.60.0030.04010.22
5.1.50.0100.03710.14
5.1.40.0070.03710.09
5.1.30.0070.03710.66
5.1.20.0000.05310.52
5.1.10.0030.05310.18
5.1.00.0030.04010.07
5.0.50.0100.0308.63
5.0.40.0000.0378.41
5.0.30.0000.0638.40
5.0.20.0070.0278.28
5.0.10.0030.0278.17
5.0.00.0070.0408.18
4.4.90.0070.0205.87
4.4.80.0030.0235.96
4.4.70.0000.0275.95
4.4.60.0070.0205.86
4.4.50.0000.0305.96
4.4.40.0000.0405.86
4.4.30.0000.0335.80
4.4.20.0030.0235.88
4.4.10.0000.0275.89
4.4.00.0100.0375.99
4.3.110.0100.0235.74
4.3.100.0070.0175.79
4.3.90.0070.0235.75
4.3.80.0070.0405.75
4.3.70.0070.0275.66
4.3.60.0030.0205.88
4.3.50.0030.0275.71
4.3.40.0030.0335.70
4.3.30.0000.0305.62
4.3.20.0000.0235.62
4.3.10.0000.0305.62
4.3.00.0000.0236.95

preferences:
37.55 ms | 401 KiB | 5 Q