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]; var_dump($parent); $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'][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.0090.00918.93
8.3.50.0130.00721.34
8.3.40.0120.00319.34
8.3.30.0130.00319.21
8.3.20.0030.00519.49
8.3.10.0080.00021.42
8.3.00.0080.00023.98
8.2.180.0150.00417.38
8.2.170.0130.00322.96
8.2.160.0030.01020.97
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00820.16
8.2.110.0070.00322.79
8.2.100.0080.00418.23
8.2.90.0030.00618.49
8.2.80.0050.00518.00
8.2.70.0060.00318.13
8.2.60.0000.00818.18
8.2.50.0040.00418.07
8.2.40.0000.00918.72
8.2.30.0000.00719.88
8.2.20.0060.00318.29
8.2.10.0040.00418.26
8.2.00.0000.00718.30
8.1.280.0140.00425.92
8.1.270.0000.00823.99
8.1.260.0110.00726.35
8.1.250.0070.00328.09
8.1.240.0060.00322.94
8.1.230.0100.00321.42
8.1.220.0050.00518.41
8.1.210.0060.00319.47
8.1.200.0060.00317.63
8.1.190.0000.00818.15
8.1.180.0030.00518.10
8.1.170.0030.00618.96
8.1.160.0040.00419.27
8.1.150.0040.00418.95
8.1.140.0000.00817.92
8.1.130.0040.00418.40
8.1.120.0000.00817.89
8.1.110.0060.00317.75
8.1.100.0000.00817.84
8.1.90.0040.00417.93
8.1.80.0030.00517.88
8.1.70.0000.00717.84
8.1.60.0040.00417.86
8.1.50.0040.00417.86
8.1.40.0030.00617.79
8.1.30.0050.00318.10
8.1.20.0040.00418.08
8.1.10.0080.00018.03
8.1.00.0060.00617.97
8.0.300.0050.00320.41
8.0.290.0040.00417.66
8.0.280.0000.00718.91
8.0.270.0040.00417.26
8.0.260.0030.00318.90
8.0.250.0000.00817.48
8.0.240.0000.00817.45
8.0.230.0000.00717.36
8.0.220.0000.00717.20
8.0.210.0030.00317.22
8.0.200.0000.00717.48
8.0.190.0000.00817.28
8.0.180.0000.00717.26
8.0.170.0020.00517.34
8.0.160.0050.00217.42
8.0.150.0040.00417.45
8.0.140.0040.00417.35
8.0.130.0100.00013.93
8.0.120.0000.00817.40
8.0.110.0050.00217.40
8.0.100.0000.00717.31
8.0.90.0000.00717.28
8.0.80.0070.01017.46
8.0.70.0070.00017.36
8.0.60.0000.00717.31
8.0.50.0000.00717.29
8.0.30.0130.00617.49
8.0.20.0110.00717.49
8.0.10.0040.00417.44
8.0.00.0090.01117.02
7.4.330.0000.00515.18
7.4.320.0070.00016.74
7.4.300.0000.00616.98
7.4.290.0030.00317.04
7.4.280.0030.00316.94
7.4.270.0040.00416.97
7.4.260.0000.00613.60
7.4.250.0050.00216.74
7.4.240.0000.00716.88
7.4.230.0030.00316.80
7.4.220.0130.00617.01
7.4.210.0110.00517.01
7.4.200.0000.00716.88
7.4.190.0000.00716.82
7.4.160.0120.00917.03
7.4.150.0070.01117.40
7.4.140.0140.00717.86
7.4.130.0080.01016.99
7.4.120.0090.00916.96
7.4.110.0140.00316.87
7.4.100.0120.01216.82
7.4.90.0070.01216.93
7.4.80.0070.01019.39
7.4.70.0030.01817.02
7.4.60.0150.00416.99
7.4.50.0000.00816.91
7.4.40.0070.01122.52
7.4.30.0120.00417.13
7.4.00.0030.01015.32
7.3.330.0030.00313.52
7.3.320.0000.00513.51
7.3.310.0000.00716.64
7.3.300.0030.00316.75
7.3.290.0080.00616.79
7.3.280.0030.01216.88
7.3.270.0180.00417.40
7.3.260.0150.00818.24
7.3.250.0070.01016.82
7.3.240.0100.00717.01
7.3.230.0030.01516.85
7.3.210.0090.00916.96
7.3.200.0140.00819.39
7.3.190.0100.01416.84
7.3.180.0090.01216.71
7.3.170.0060.01116.75
7.3.160.0110.00616.76
7.3.120.0000.01515.23
7.3.10.0110.00017.07
7.3.00.0070.00716.80
7.2.330.0110.00716.91
7.2.320.0070.01117.29
7.2.310.0130.01316.79
7.2.300.0100.00616.93
7.2.290.0090.00917.19
7.2.130.0100.00317.08
7.2.120.0000.01116.94
7.2.110.0090.00316.89
7.2.100.0080.00817.14
7.2.90.0030.01016.95
7.2.80.0030.00916.77
7.2.70.0030.01017.29
7.2.60.0060.00517.10
7.2.50.0000.01417.20
7.2.40.0000.01317.14
7.2.30.0030.01017.21
7.2.20.0090.00617.06
7.2.10.0050.00517.06
7.2.00.0070.00718.35
7.1.250.0070.00315.99
7.1.200.0040.01216.08
7.1.100.0060.00618.17
7.1.70.0050.00217.28
7.1.60.0070.01419.40
7.1.50.0140.01017.07
7.1.00.0030.05322.64
7.0.200.0000.00716.79
7.0.140.0000.07722.14
7.0.90.0070.04320.13
7.0.80.0100.07020.13
7.0.70.0100.08020.17
7.0.60.0130.08020.24
7.0.50.0430.04720.53
7.0.40.0170.08020.26
7.0.30.0230.06320.22
7.0.20.0100.06720.22
7.0.10.0070.08320.26
7.0.00.0170.07320.34
5.6.280.0100.06721.10
5.6.230.0070.07020.88
5.6.220.0130.08020.90
5.6.210.0100.05320.97
5.6.200.0030.05721.30
5.6.190.0100.05321.27
5.6.180.0030.06021.19
5.6.170.0070.08021.21
5.6.160.0030.06021.21
5.6.150.0170.07021.25
5.6.140.0170.07321.21
5.6.130.0070.07321.19
5.6.120.0100.07321.37
5.6.110.0000.10021.34
5.6.100.0030.08721.36
5.6.90.0070.05321.14
5.6.80.0030.04720.66
5.6.70.0070.08020.67
5.6.60.0130.07020.58
5.6.50.0130.07720.60
5.6.40.0070.07720.52
5.6.30.0130.07720.59
5.6.20.0030.04720.49
5.6.10.0070.07020.52
5.6.00.0130.06720.48
5.5.370.0100.06320.66
5.5.360.0070.08320.54
5.5.350.0070.06720.58
5.5.340.0000.07721.04
5.5.330.0030.08021.12
5.5.320.0100.08020.95
5.5.310.0230.06021.06
5.5.300.0130.07321.11
5.5.290.0130.08320.91
5.5.280.0070.06021.12
5.5.270.0100.08321.02
5.5.260.0070.05320.91
5.5.250.0130.08020.93
5.5.240.0130.06720.40
5.5.230.0100.07020.41
5.5.220.0070.08320.34
5.5.210.0070.06020.44
5.5.200.0130.07020.36
5.5.190.0130.06720.44
5.5.180.0170.05720.44
5.5.160.0030.08020.39
5.5.150.0130.07320.40
5.5.140.0130.06720.39
5.5.130.0070.06320.39
5.5.120.0030.06320.25
5.5.110.0070.06320.46
5.5.100.0130.06720.34
5.5.90.0100.05720.36
5.5.80.0030.04020.18
5.5.70.0070.08020.27
5.5.60.0070.05020.26
5.5.50.0130.07020.20
5.5.40.0100.07020.34
5.5.30.0170.07320.29
5.5.20.0130.06320.25
5.5.10.0100.05020.21
5.5.00.0070.07720.16
5.4.450.0070.08719.67
5.4.440.0000.08719.65
5.4.430.0170.06019.52
5.4.420.0070.07019.72
5.4.410.0030.05719.38
5.4.400.0130.04719.13
5.4.390.0070.06019.13
5.4.380.0170.05319.41
5.4.370.0230.05319.40
5.4.360.0130.07019.18
5.4.350.0130.06719.18
5.4.340.0070.05319.13
5.4.320.0100.08019.40
5.4.310.0070.06719.18
5.4.300.0070.07319.18
5.4.290.0170.07019.14
5.4.280.0070.08019.20
5.4.270.0030.08719.30
5.4.260.0030.05719.31
5.4.250.0030.07719.17
5.4.240.0130.03719.34
5.4.230.0030.05719.31
5.4.220.0100.07719.17
5.4.210.0100.05319.31
5.4.200.0000.08719.08
5.4.190.0030.04319.19
5.4.180.0130.06719.32
5.4.170.0170.06719.32
5.4.160.0130.06719.29
5.4.150.0030.07319.34
5.4.140.0070.06716.54
5.4.130.0130.05316.70
5.4.120.0070.07316.72
5.4.110.0100.06316.65
5.4.100.0030.04016.63
5.4.90.0030.07316.84
5.4.80.0100.07016.65
5.4.70.0170.04016.68
5.4.60.0030.03716.64
5.4.50.0170.05316.66
5.4.40.0070.05316.64
5.4.30.0070.07316.63
5.4.20.0070.06716.62
5.4.10.0070.05016.64
5.4.00.0130.06316.15
5.3.290.0070.05714.91
5.3.280.0070.07714.91
5.3.270.0030.07714.84
5.3.260.0070.04714.92
5.3.250.0070.07314.84
5.3.240.0300.04314.83
5.3.230.0030.06714.90
5.3.220.0130.06014.80
5.3.210.0030.07314.79
5.3.200.0000.04314.91
5.3.190.0100.03714.80
5.3.180.0070.04014.88
5.3.170.0030.07314.88
5.3.160.0030.07314.75
5.3.150.0130.07314.83
5.3.140.0100.06714.76
5.3.130.0070.05714.73
5.3.120.0170.06314.87
5.3.110.0070.07014.77
5.3.100.0100.06714.25
5.3.90.0030.05714.18
5.3.80.0000.04014.32
5.3.70.0070.03714.28
5.3.60.0000.05014.21
5.3.50.0070.05014.18
5.3.40.0070.06314.17
5.3.30.0030.06714.18
5.3.20.0030.07714.00
5.3.10.0030.03713.89
5.3.00.0070.07013.79
5.2.170.0030.06013.60
5.2.160.0070.06013.60
5.2.150.0200.04713.60
5.2.140.0070.03713.60
5.2.130.0100.04713.60
5.2.120.0000.03313.60
5.2.110.0070.05013.60
5.2.100.0000.04713.60
5.2.90.0070.06013.60
5.2.80.0070.06013.60
5.2.70.0030.04313.60
5.2.60.0000.03313.60
5.2.50.0070.04313.60
5.2.40.0030.04313.60
5.2.30.0030.05313.60
5.2.20.0130.05313.60
5.2.10.0070.06013.60
5.2.00.0070.04713.60
5.1.60.0070.05313.60
5.1.50.0030.05713.60
5.1.40.0070.05013.60
5.1.30.0000.05713.60
5.1.20.0030.05713.60
5.1.10.0030.05313.60
5.1.00.0100.03713.60
5.0.50.0070.04013.60
5.0.40.0030.03313.60
5.0.30.0000.06713.60
5.0.20.0000.03013.60
5.0.10.0030.04313.60
5.0.00.0030.06013.60
4.4.90.0030.01313.60
4.4.80.0000.03313.60
4.4.70.0070.02313.60
4.4.60.0070.02013.60
4.4.50.0030.03313.60
4.4.40.0030.05313.60
4.4.30.0000.02013.60
4.4.20.0030.03313.60
4.4.10.0000.03713.60
4.4.00.0070.05313.60
4.3.110.0030.03313.60
4.3.100.0030.02313.60
4.3.90.0030.03313.60
4.3.80.0070.05313.60
4.3.70.0030.02313.60
4.3.60.0000.03313.60
4.3.50.0030.02313.60
4.3.40.0030.05013.60
4.3.30.0000.03313.60
4.3.20.0000.04013.60
4.3.10.0000.03713.60
4.3.00.0000.03313.60

preferences:
51.51 ms | 401 KiB | 5 Q