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 . '[' . $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'][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.67
8.3.50.0120.00722.23
8.3.40.0000.01519.09
8.3.30.0040.01119.65
8.3.20.0040.00420.46
8.3.10.0080.00022.29
8.3.00.0040.00422.81
8.2.180.0080.00817.00
8.2.170.0040.01122.96
8.2.160.0090.00921.51
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0090.00926.16
8.2.120.0060.00318.25
8.2.110.0060.00322.54
8.2.100.0060.00618.16
8.2.90.0040.00419.72
8.2.80.0050.00318.38
8.2.70.0030.00718.13
8.2.60.0000.00818.41
8.2.50.0060.00318.25
8.2.40.0050.00318.59
8.2.30.0090.00018.51
8.2.20.0050.00318.14
8.2.10.0040.00418.16
8.2.00.0030.00618.18
8.1.280.0110.00725.92
8.1.270.0050.00322.63
8.1.260.0070.00326.35
8.1.250.0050.00328.09
8.1.240.0060.00323.94
8.1.230.0040.00719.51
8.1.220.0040.00418.28
8.1.210.0040.00418.77
8.1.200.0030.00717.85
8.1.190.0000.00818.03
8.1.180.0040.00419.18
8.1.170.0040.00418.92
8.1.160.0070.00022.34
8.1.150.0000.00819.14
8.1.140.0030.00517.91
8.1.130.0000.00718.29
8.1.120.0040.00417.80
8.1.110.0050.00317.84
8.1.100.0000.00717.90
8.1.90.0040.00417.84
8.1.80.0040.00417.79
8.1.70.0000.00717.91
8.1.60.0060.00317.86
8.1.50.0000.00817.89
8.1.40.0080.00018.01
8.1.30.0040.00418.15
8.1.20.0050.00318.08
8.1.10.0050.00317.83
8.1.00.0050.00317.98
8.0.300.0070.00018.77
8.0.290.0050.00217.66
8.0.280.0070.00018.79
8.0.270.0040.00417.57
8.0.260.0030.00317.27
8.0.250.0000.00717.48
8.0.240.0080.00017.43
8.0.230.0070.00017.44
8.0.220.0030.00317.42
8.0.210.0030.00317.34
8.0.200.0030.00317.43
8.0.190.0040.00417.45
8.0.180.0040.00417.29
8.0.170.0030.00617.26
8.0.160.0070.00317.50
8.0.150.0000.00817.36
8.0.140.0000.00717.20
8.0.130.0000.00613.68
8.0.120.0000.00817.38
8.0.110.0000.00717.32
8.0.100.0000.00717.22
8.0.90.0040.00417.29
8.0.80.0060.01017.28
8.0.70.0040.00417.34
8.0.60.0040.00417.42
8.0.50.0000.00717.30
8.0.30.0090.01017.60
8.0.20.0100.00917.54
8.0.10.0000.00717.52
8.0.00.0080.01116.96
7.4.330.0030.00315.00
7.4.320.0000.00616.96
7.4.300.0030.00317.03
7.4.290.0070.00016.96
7.4.280.0030.00316.98
7.4.270.0070.00017.08
7.4.260.0000.00716.92
7.4.250.0090.00016.88
7.4.240.0040.00417.03
7.4.230.0000.00716.99
7.4.220.0090.00916.96
7.4.210.0060.01116.98
7.4.200.0000.00716.93
7.4.190.0000.00817.21
7.4.160.0000.01716.80
7.4.150.0110.00617.40
7.4.140.0080.01017.86
7.4.130.0120.00617.21
7.4.120.0140.00416.91
7.4.110.0100.00717.09
7.4.100.0120.01216.96
7.4.90.0050.01817.00
7.4.80.0090.00919.39
7.4.70.0070.01016.91
7.4.60.0030.01316.96
7.4.50.0000.00816.81
7.4.40.0040.01522.77
7.4.30.0070.01016.95
7.4.00.0000.01815.27
7.3.330.0050.00213.88
7.3.320.0030.00313.79
7.3.310.0070.00016.89
7.3.300.0070.00016.86
7.3.290.0070.01216.83
7.3.280.0090.01016.86
7.3.270.0040.01417.40
7.3.260.0130.01316.94
7.3.250.0080.01317.09
7.3.240.0140.00716.88
7.3.230.0120.00616.90
7.3.210.0030.01416.78
7.3.200.0140.00919.39
7.3.190.0030.01517.12
7.3.180.0090.00616.93
7.3.170.0100.01316.93
7.3.160.0000.01716.93
7.3.120.0100.00715.07
7.2.330.0070.01016.82
7.2.320.0090.00617.02
7.2.310.0070.01017.18
7.2.300.0040.01317.13
7.2.290.0090.00917.23
7.2.60.0000.01417.14
7.1.200.0110.00316.18
7.1.100.0060.00918.38
7.1.70.0000.01117.21
7.1.60.0070.01819.82
7.1.50.0000.02217.28
7.1.00.0130.06722.61
7.0.200.0000.00717.13
7.0.140.0000.07322.27
7.0.100.0170.07320.18
7.0.90.0130.04320.30
7.0.80.0100.07320.08
7.0.70.0130.08020.29
7.0.60.0100.05020.18
7.0.50.0130.07720.43
7.0.40.0070.03720.18
7.0.30.0170.07020.16
7.0.20.0000.04320.28
7.0.10.0130.07020.30
7.0.00.0000.08020.22
5.6.280.0030.07321.18
5.6.250.0030.08320.75
5.6.240.0130.07320.81
5.6.230.0130.05720.76
5.6.220.0030.07320.75
5.6.210.0100.04721.05
5.6.200.0100.08321.25
5.6.190.0100.04721.16
5.6.180.0100.07721.23
5.6.170.0100.07021.22
5.6.160.0170.07321.19
5.6.150.0130.07721.32
5.6.140.0070.08321.23
5.6.130.0070.09021.18
5.6.120.0030.08721.21
5.6.110.0230.07021.30
5.6.100.0030.05721.16
5.6.90.0100.07321.35
5.6.80.0100.07720.54
5.6.70.0170.07020.59
5.6.60.0130.07320.52
5.6.50.0030.05020.63
5.6.40.0000.05320.63
5.6.30.0200.06320.64
5.6.20.0030.07720.54
5.6.10.0100.07020.65
5.6.00.0170.07020.48
5.5.380.0170.04320.55
5.5.370.0070.05020.76
5.5.360.0070.07720.54
5.5.350.0130.07320.63
5.5.340.0030.08721.12
5.5.330.0130.07720.96
5.5.320.0100.07720.94
5.5.310.0070.03721.13
5.5.300.0170.08021.10
5.5.290.0070.07321.00
5.5.280.0030.06321.08
5.5.270.0200.07721.12
5.5.260.0030.06021.11
5.5.250.0130.08020.79
5.5.240.0070.08020.30
5.5.230.0070.04720.46
5.5.220.0070.07320.31
5.5.210.0070.08020.50
5.5.200.0130.07020.42
5.5.190.0070.06020.29
5.5.180.0070.07720.29
5.5.160.0030.07320.45
5.5.150.0130.07020.39
5.5.140.0100.07020.42
5.5.130.0070.04320.39
5.5.120.0070.07020.31
5.5.110.0000.08020.43
5.5.100.0070.07720.22
5.5.90.0070.08020.25
5.5.80.0100.06320.21
5.5.70.0170.07020.20
5.5.60.0070.06320.16
5.5.50.0130.07320.26
5.5.40.0070.08720.32
5.5.30.0070.08320.21
5.5.20.0200.06320.16
5.5.10.0070.08020.22
5.5.00.0100.04320.20
5.4.450.0070.08319.64
5.4.440.0070.07719.63
5.4.430.0100.07719.66
5.4.420.0170.07019.63
5.4.410.0100.07019.64
5.4.400.0070.07319.06
5.4.390.0030.06719.30
5.4.380.0130.07319.33
5.4.370.0070.06319.32
5.4.360.0100.07719.20
5.4.350.0070.08019.33
5.4.340.0100.06719.30
5.4.320.0030.05719.31
5.4.310.0200.06319.32
5.4.300.0130.07019.32
5.4.290.0130.06319.40
5.4.280.0130.07319.42
5.4.270.0000.05719.16
5.4.260.0000.07019.30
5.4.250.0030.07319.17
5.4.240.0070.06719.39
5.4.230.0070.07319.36
5.4.220.0030.08319.29
5.4.210.0070.05319.36
5.4.200.0100.08019.32
5.4.190.0130.06719.43
5.4.180.0130.07019.07
5.4.170.0030.05319.17
5.4.160.0030.05319.32
5.4.150.0070.06019.31
5.4.140.0030.03716.71
5.4.130.0030.03316.61
5.4.120.0030.04016.59
5.4.110.0030.05016.61
5.4.100.0030.03716.66
5.4.90.0030.03316.64
5.4.80.0030.03316.72
5.4.70.0030.03716.64
5.4.60.0000.03716.64
5.4.50.0070.07016.64
5.4.40.0100.06316.70
5.4.30.0070.06716.62
5.4.20.0030.06716.75
5.4.10.0030.03716.63
5.4.00.0030.03716.19
5.3.290.0030.05014.88
5.3.280.0030.07714.78
5.3.270.0070.05714.84
5.3.260.0070.05714.84
5.3.250.0070.03314.87
5.3.240.0030.03714.93
5.3.230.0000.04014.78
5.3.220.0070.03314.80
5.3.210.0070.04714.73
5.3.200.0030.04014.82
5.3.190.0000.04014.83
5.3.180.0000.04014.91
5.3.170.0070.03714.88
5.3.160.0070.07014.79
5.3.150.0100.07014.79
5.3.140.0100.07714.87
5.3.130.0030.07314.91
5.3.120.0070.07714.79
5.3.110.0100.06714.77
5.3.100.0130.03014.27
5.3.90.0030.04314.20
5.3.80.0030.04314.32
5.3.70.0030.03314.32
5.3.60.0070.04714.21
5.3.50.0000.04314.26
5.3.40.0070.03314.08
5.3.30.0030.05314.21
5.3.20.0000.04014.00
5.3.10.0070.03313.96
5.3.00.0000.04013.86
5.2.170.0000.03311.46
5.2.160.0030.05011.46
5.2.150.0000.03011.26
5.2.140.0000.03011.36
5.2.130.0030.03011.26
5.2.120.0030.02711.41
5.2.110.0030.04311.24
5.2.100.0030.02711.33
5.2.90.0000.03011.22
5.2.80.0000.03311.32
5.2.70.0070.02711.23
5.2.60.0000.03011.35
5.2.50.0030.03711.29
5.2.40.0000.03011.31
5.2.30.0030.02711.33
5.2.20.0000.03711.22
5.2.10.0000.03011.09
5.2.00.0000.03010.95
5.1.60.0030.02010.17
5.1.50.0000.02710.37
5.1.40.0000.05010.17
5.1.30.0000.02710.55
5.1.20.0070.02310.58
5.1.10.0030.05010.15
5.1.00.0070.03310.17
5.0.50.0030.0239.20
5.0.40.0000.0209.20
5.0.30.0000.0509.20
5.0.20.0000.0279.20
5.0.10.0000.0209.20
5.0.00.0030.0339.20
4.4.90.0000.0179.20
4.4.80.0000.0179.20
4.4.70.0030.0139.20
4.4.60.0030.0209.20
4.4.50.0030.0279.20
4.4.40.0000.0279.20
4.4.30.0000.0179.20
4.4.20.0000.0179.20
4.4.10.0030.0179.20
4.4.00.0000.0279.20
4.3.110.0000.0239.20
4.3.100.0000.0139.20
4.3.90.0030.0139.20
4.3.80.0000.0239.20
4.3.70.0030.0139.20
4.3.60.0000.0179.20
4.3.50.0070.0109.20
4.3.40.0000.0279.20
4.3.30.0000.0179.20
4.3.20.0000.0309.20
4.3.10.0000.0179.20
4.3.00.0030.0139.20

preferences:
47.06 ms | 401 KiB | 5 Q