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']; echo $xml['note']['recursive']['val'][2];

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.40.0080.00819.17
8.3.30.0030.01219.21
8.3.20.0060.00919.10
8.3.10.0060.00321.55
8.3.00.0000.00823.86
8.2.170.0060.00922.96
8.2.160.0100.00320.77
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00021.59
8.2.110.0060.00320.97
8.2.100.0040.00818.28
8.2.90.0040.00419.67
8.2.80.0050.00318.41
8.2.70.0030.00518.00
8.2.60.0040.00418.30
8.2.50.0040.00418.13
8.2.40.0060.00318.59
8.2.30.0040.00420.30
8.2.20.0000.00818.12
8.2.10.0040.00418.14
8.2.00.0000.00818.18
8.1.270.0040.00423.99
8.1.260.0040.01526.35
8.1.250.0040.00428.09
8.1.240.0060.00323.00
8.1.230.0060.00621.54
8.1.220.0040.00418.77
8.1.210.0040.00419.36
8.1.200.0030.00617.88
8.1.190.0040.00419.57
8.1.180.0040.00418.26
8.1.170.0030.00619.03
8.1.160.0000.00719.22
8.1.150.0050.00319.03
8.1.140.0040.00417.93
8.1.130.0000.00718.28
8.1.120.0040.00417.88
8.1.110.0040.00417.77
8.1.100.0030.00617.79
8.1.90.0000.00717.70
8.1.80.0040.00417.94
8.1.70.0000.00717.91
8.1.60.0080.00017.93
8.1.50.0000.00817.91
8.1.40.0040.00418.00
8.1.30.0040.00417.89
8.1.20.0030.00518.07
8.1.10.0090.00017.93
8.1.00.0080.00017.85
8.0.300.0030.00520.39
8.0.290.0050.00217.66
8.0.280.0080.00018.86
8.0.270.0040.00417.71
8.0.260.0040.00417.33
8.0.250.0050.00217.48
8.0.240.0050.00317.48
8.0.230.0030.00417.45
8.0.220.0040.00417.40
8.0.210.0000.00717.28
8.0.200.0040.00417.24
8.0.190.0060.00317.22
8.0.180.0040.00717.18
8.0.170.0050.00317.44
8.0.160.0080.00017.37
8.0.150.0050.00317.32
8.0.140.0050.00217.31
8.0.130.0030.00313.83
8.0.120.0040.00417.35
8.0.110.0000.00817.27
8.0.100.0080.00017.27
8.0.90.0040.00417.30
8.0.80.0090.00617.33
8.0.70.0000.00717.22
8.0.60.0030.00617.32
8.0.50.0030.00617.15
8.0.30.0110.01117.55
8.0.20.0110.00817.52
8.0.10.0040.00417.64
8.0.00.0100.01017.22
7.4.330.0000.00515.02
7.4.320.0040.00416.92
7.4.300.0070.00016.89
7.4.290.0030.00616.93
7.4.280.0060.00516.99
7.4.270.0000.00717.07
7.4.260.0050.00013.71
7.4.250.0030.00516.95
7.4.240.0000.00716.98
7.4.230.0040.00416.88
7.4.220.0060.01316.90
7.4.210.0030.01217.00
7.4.200.0030.00316.79
7.4.190.0030.00516.97
7.4.160.0130.00316.86
7.4.150.0150.00317.40
7.4.140.0090.01117.86
7.4.130.0120.00817.00
7.4.120.0050.01116.94
7.4.110.0060.01017.08
7.4.100.0060.01216.91
7.4.90.0030.01316.89
7.4.80.0140.00419.37
7.4.70.0040.01716.89
7.4.60.0090.00916.98
7.4.50.0050.00317.07
7.4.40.0090.00622.27
7.4.30.0120.00616.96
7.4.00.0050.01015.17
7.3.330.0030.00313.70
7.3.320.0030.00313.63
7.3.310.0000.00716.84
7.3.300.0030.00516.87
7.3.290.0060.00916.89
7.3.280.0100.00616.87
7.3.270.0140.00317.40
7.3.260.0090.00918.24
7.3.250.0130.00716.91
7.3.240.0060.01116.93
7.3.230.0100.00717.05
7.3.210.0070.01416.91
7.3.200.0100.00619.39
7.3.190.0080.01516.74
7.3.180.0030.01416.75
7.3.170.0090.00916.95
7.3.160.0100.00717.04
7.3.120.0090.00915.26
7.3.110.0100.00715.17
7.3.100.0070.01015.15
7.3.90.0070.01115.01
7.3.80.0070.01314.96
7.3.70.0100.01115.21
7.3.60.0000.01015.05
7.3.50.0030.01014.98
7.3.40.0030.01414.95
7.3.30.0090.00415.10
7.3.20.0090.00616.94
7.3.10.0030.00916.82
7.3.00.0030.01317.01
7.2.330.0170.00017.08
7.2.320.0120.00717.21
7.2.310.0040.01317.14
7.2.300.0080.00817.24
7.2.290.0040.01416.98
7.2.250.0070.01015.28
7.2.240.0040.01515.48
7.2.230.0070.01015.36
7.2.220.0030.00715.26
7.2.210.0060.01615.27
7.2.200.0030.01015.22
7.2.190.0040.01115.31
7.2.180.0080.00815.35
7.2.170.0100.01015.17
7.2.130.0030.01017.14
7.2.120.0090.00617.08
7.2.110.0060.00617.06
7.2.100.0040.00817.08
7.2.90.0090.00017.21
7.2.80.0070.00417.18
7.2.70.0030.00917.17
7.2.60.0030.00917.14
7.2.50.0070.00717.00
7.2.40.0080.00417.21
7.2.30.0030.00817.24
7.2.20.0000.01217.01
7.2.10.0030.00917.08
7.2.00.0070.00518.39
7.1.330.0070.00716.26
7.1.320.0070.01016.02
7.1.310.0070.01115.94
7.1.300.0000.01015.99
7.1.290.0060.00915.88
7.1.280.0060.01315.85
7.1.270.0090.00915.88
7.1.260.0070.00715.92
7.1.250.0070.00715.91
7.1.200.0070.00716.07
7.1.100.0080.00418.42
7.1.70.0000.00817.55
7.1.60.0140.01019.40
7.1.50.0090.00917.03
7.1.00.0130.06022.59
7.0.200.0080.00016.65
7.0.140.0030.07322.21
7.0.70.0000.08021.98
7.0.60.0070.08021.89
7.0.50.0030.07322.28
7.0.40.0030.07020.36
7.0.30.0170.07720.25
7.0.20.0030.09320.20
7.0.10.0130.07020.29
7.0.00.0070.07720.31
5.6.280.0100.06721.12
5.6.220.0100.07720.82
5.6.210.0030.08020.68
5.6.200.0100.07321.24
5.6.190.0070.07721.24
5.6.180.0030.08721.22
5.6.170.0070.08721.14
5.6.160.0000.07321.27
5.6.150.0070.07321.19
5.6.140.0070.05721.30
5.6.130.0000.09021.21
5.6.120.0000.05721.21
5.6.110.0070.04721.20
5.6.100.0030.08721.36
5.6.90.0100.08021.15
5.6.80.0030.06020.73
5.6.70.0030.08720.60
5.6.60.0070.06720.58
5.6.50.0070.08020.49
5.6.40.0100.07020.47
5.6.30.0030.05020.53
5.6.20.0070.07320.63
5.6.10.0030.05720.72
5.6.00.0030.07720.57
5.5.360.0130.07320.50
5.5.350.0070.07020.54
5.5.340.0030.08021.03
5.5.330.0070.07720.91
5.5.320.0100.07321.09
5.5.310.0000.07720.91
5.5.300.0030.08021.03
5.5.290.0030.08021.03
5.5.280.0000.06721.04
5.5.270.0000.08721.11
5.5.260.0100.06321.01
5.5.250.0130.05020.93
5.5.240.0070.07720.39
5.5.230.0030.06320.28
5.5.220.0100.06720.40
5.5.210.0030.08020.50
5.5.200.0100.07020.41
5.5.190.0070.08320.33
5.5.180.0030.08320.40
5.5.160.0030.08320.29
5.5.150.0030.08020.29
5.5.140.0070.07720.29
5.5.130.0100.05720.38
5.5.120.0030.05720.28
5.5.110.0070.07720.40
5.5.100.0130.07020.22
5.5.90.0070.07720.30
5.5.80.0000.07720.21
5.5.70.0070.07720.30
5.5.60.0030.07720.25
5.5.50.0130.06720.16
5.5.40.0070.07320.20
5.5.30.0030.07320.34
5.5.20.0030.08020.22
5.5.10.0100.07020.21
5.5.00.0030.07020.24
5.4.450.0000.07319.39
5.4.440.0030.06719.67
5.4.430.0100.05719.49
5.4.420.0000.04319.63
5.4.410.0030.05719.38
5.4.400.0000.07719.33
5.4.390.0070.06719.44
5.4.380.0100.07019.36
5.4.370.0070.06719.36
5.4.360.0030.08019.32
5.4.350.0070.04319.06
5.4.340.0030.07319.32
5.4.320.0000.07319.33
5.4.310.0030.07719.30
5.4.300.0030.06319.35
5.4.290.0030.08019.44
5.4.280.0100.08019.08
5.4.270.0070.07019.32
5.4.260.0070.07719.18
5.4.250.0030.07319.09
5.4.240.0100.06719.19
5.4.230.0000.06319.33
5.4.220.0100.03719.31
5.4.210.0170.07019.18
5.4.200.0070.07019.32
5.4.190.0030.06019.09
5.4.180.0030.07719.17
5.4.170.0070.06319.09
5.4.160.0070.07319.17
5.4.150.0070.07719.24
5.4.140.0030.07316.64
5.4.130.0000.07716.64
5.4.120.0000.05316.69
5.4.110.0100.05716.77
5.4.100.0030.07016.61
5.4.90.0030.07316.84
5.4.80.0030.07316.63
5.4.70.0030.07016.66
5.4.60.0030.06716.64
5.4.50.0070.07016.65
5.4.40.0030.07716.55
5.4.30.0070.06716.64
5.4.20.0070.07016.54
5.4.10.0000.07716.62
5.4.00.0070.04316.12
5.3.290.0030.08014.98
5.3.280.0000.07714.81
5.3.270.0000.08014.84
5.3.260.0070.07314.81
5.3.250.0070.07014.91
5.3.240.0130.06314.95
5.3.230.0070.06714.95
5.3.220.0070.06314.88
5.3.210.0070.07314.75
5.3.200.0070.06714.79
5.3.190.0030.07014.73
5.3.180.0070.07014.77
5.3.170.0030.07314.79
5.3.160.0100.07314.86
5.3.150.0000.07314.80
5.3.140.0000.07714.88
5.3.130.0070.06714.82
5.3.120.0000.06714.77
5.3.110.0030.08014.91
5.3.100.0070.07014.39
5.3.90.0030.06714.18
5.3.80.0000.07714.29
5.3.70.0070.06314.25
5.3.60.0000.07314.12
5.3.50.0070.07314.21
5.3.40.0070.07014.21
5.3.30.0000.07314.22
5.3.20.0030.07713.95
5.3.10.0100.06713.78
5.3.00.0070.06713.97
5.2.170.0000.05711.27
5.2.160.0070.05711.49
5.2.150.0030.06311.38
5.2.140.0030.05711.44
5.2.130.0070.05711.36
5.2.120.0000.05311.32
5.2.110.0070.05011.34
5.2.100.0030.05711.34
5.2.90.0000.05711.37
5.2.80.0000.06711.23
5.2.70.0000.05711.40
5.2.60.0030.06711.36
5.2.50.0000.06311.15
5.2.40.0030.06311.16
5.2.30.0000.06311.23
5.2.20.0030.06311.18
5.2.10.0070.05311.18
5.2.00.0000.06310.94
5.1.60.0030.05310.22
5.1.50.0030.06010.29
5.1.40.0000.05310.15
5.1.30.0070.05310.56
5.1.20.0070.06010.57
5.1.10.0000.05710.13
5.1.00.0030.05010.21
5.0.50.0000.0508.97
5.0.40.0030.0378.97
5.0.30.0000.0678.97
5.0.20.0070.0408.97
5.0.10.0000.0408.97
5.0.00.0030.0538.97
4.4.90.0000.0378.97
4.4.80.0000.0338.97
4.4.70.0000.0378.97
4.4.60.0000.0378.97
4.4.50.0000.0378.97
4.4.40.0000.0478.97
4.4.30.0030.0338.97
4.4.20.0070.0378.97
4.4.10.0000.0408.97
4.4.00.0070.0408.97
4.3.110.0000.0408.97
4.3.100.0000.0338.97
4.3.90.0000.0338.97
4.3.80.0030.0508.97
4.3.70.0000.0308.97
4.3.60.0030.0338.97
4.3.50.0030.0278.97
4.3.40.0070.0408.97
4.3.30.0070.0308.97
4.3.20.0070.0338.97
4.3.10.0030.0338.97
4.3.00.0030.0278.97

preferences:
46.14 ms | 400 KiB | 5 Q