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(); var_dump($tag); $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'][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.40.0000.01519.34
8.3.30.0040.01219.61
8.3.20.0040.00420.70
8.3.10.0040.00422.50
8.3.00.0040.00422.79
8.2.170.0210.00022.96
8.2.160.0110.00421.39
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0170.00326.16
8.2.120.0030.00618.25
8.2.110.0090.00021.07
8.2.100.0090.00318.41
8.2.90.0090.00019.59
8.2.80.0080.00018.30
8.2.70.0070.00418.25
8.2.60.0050.00518.42
8.2.50.0050.00318.13
8.2.40.0000.00918.59
8.2.30.0000.00718.46
8.2.20.0050.00318.19
8.2.10.0060.00319.90
8.2.00.0000.00818.38
8.1.270.0000.00824.34
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0000.01022.89
8.1.230.0040.00821.27
8.1.220.0000.00818.02
8.1.210.0080.00018.77
8.1.200.0060.00317.75
8.1.190.0040.00417.93
8.1.180.0030.00718.10
8.1.170.0000.00919.02
8.1.160.0000.00722.40
8.1.150.0040.00419.01
8.1.140.0080.00017.80
8.1.130.0000.00718.27
8.1.120.0000.00718.00
8.1.110.0040.00417.85
8.1.100.0000.00817.94
8.1.90.0050.00317.71
8.1.80.0040.00417.99
8.1.70.0080.00017.75
8.1.60.0040.00418.09
8.1.50.0040.00417.86
8.1.40.0030.00518.00
8.1.30.0060.00318.07
8.1.20.0030.00518.12
8.1.10.0040.00418.01
8.1.00.0040.00417.81
8.0.300.0070.00018.77
8.0.290.0040.00417.68
8.0.280.0030.00318.78
8.0.270.0000.00717.63
8.0.260.0060.00317.35
8.0.250.0080.00017.36
8.0.240.0040.00417.33
8.0.230.0000.00817.45
8.0.220.0050.00317.39
8.0.210.0030.00317.43
8.0.200.0000.00617.38
8.0.190.0000.00817.30
8.0.180.0030.00517.32
8.0.170.0030.00517.45
8.0.160.0000.00917.39
8.0.150.0000.00717.36
8.0.140.0040.00417.26
8.0.130.0000.00713.87
8.0.120.0000.00817.36
8.0.110.0040.00417.38
8.0.100.0030.00517.35
8.0.90.0040.00417.28
8.0.80.0090.00617.39
8.0.70.0000.00717.35
8.0.60.0040.00417.37
8.0.50.0040.00417.52
8.0.30.0130.01017.51
8.0.20.0140.00517.63
8.0.10.0000.00717.50
8.0.00.0070.01117.35
7.4.330.0000.00515.40
7.4.320.0040.00417.05
7.4.300.0030.00317.01
7.4.290.0050.00216.98
7.4.280.0000.00817.12
7.4.270.0070.00317.02
7.4.260.0030.00616.99
7.4.250.0000.00716.86
7.4.240.0040.00417.02
7.4.230.0060.00316.86
7.4.220.0110.00717.05
7.4.210.0060.00916.99
7.4.200.0070.00016.96
7.4.190.0030.00317.04
7.4.160.0120.00416.95
7.4.150.0090.00917.40
7.4.140.0080.01317.86
7.4.130.0150.00416.91
7.4.120.0100.01316.98
7.4.110.0140.00417.16
7.4.100.0080.01216.91
7.4.90.0040.01416.88
7.4.80.0070.01516.93
7.4.70.0170.00016.86
7.4.60.0160.00017.01
7.4.50.0040.00016.93
7.4.40.0020.01622.77
7.4.30.0100.00716.90
7.4.00.0120.00415.43
7.3.330.0050.00013.69
7.3.320.0050.00013.85
7.3.310.0030.00316.93
7.3.300.0070.00016.79
7.3.290.0100.00716.83
7.3.280.0080.00816.82
7.3.270.0060.01317.40
7.3.260.0070.01116.82
7.3.250.0080.01317.04
7.3.240.0130.01016.86
7.3.230.0090.00917.09
7.3.210.0110.00717.18
7.3.200.0070.01419.39
7.3.190.0120.00616.83
7.3.180.0100.01016.85
7.3.170.0120.00616.80
7.3.160.0080.00816.80
7.3.120.0130.00315.34
7.2.330.0090.00917.18
7.2.320.0070.01017.21
7.2.310.0040.01517.02
7.2.300.0110.00617.09
7.2.290.0110.00517.11
7.2.80.0000.00916.76
7.2.60.0140.00017.09
7.2.50.0000.01217.06
7.1.200.0100.00716.16
7.1.70.0030.01317.46
7.1.60.0070.00417.50
7.1.50.0290.01034.94
7.1.00.0070.07322.57
7.0.200.0030.01417.10
7.0.140.0100.06322.13
7.0.60.0170.07020.30
7.0.50.0000.09018.25
7.0.40.0070.09020.47
7.0.30.0330.07720.39
7.0.20.0370.04020.46
7.0.10.0370.07320.29
7.0.00.0000.09720.38
5.6.280.0070.06721.27
5.6.210.0000.04320.83
5.6.200.0130.08018.29
5.6.190.0170.06720.85
5.6.180.3300.03720.62
5.6.170.0500.06320.70
5.6.160.0070.08020.77
5.6.150.0130.07318.45
5.6.140.0070.06018.46
5.6.130.0130.06318.27
5.6.120.0030.07321.28
5.6.110.0100.08721.16
5.6.100.0100.07721.18
5.6.90.0000.08721.15
5.6.80.0030.07320.65
5.6.70.3830.03720.55
5.5.350.0030.05320.58
5.5.340.0070.08318.21
5.5.330.0130.07720.66
5.5.320.0200.05020.46
5.5.310.0330.06020.56
5.5.300.0100.07718.21
5.5.290.0070.04018.17
5.5.280.0100.08021.01
5.5.270.0100.08020.95
5.5.260.0130.07721.11
5.5.250.0200.06720.74
5.5.240.0100.06020.32
5.4.450.0300.05019.64
5.4.440.0600.02719.77
5.4.430.0470.04019.75
5.4.420.0630.04019.56
5.4.410.0130.05319.20
5.4.400.0100.05319.05
5.4.390.0130.05019.02
5.4.380.0200.05018.84
5.4.370.0130.06018.92
5.4.360.0130.05318.88
5.4.350.0130.05718.98
5.4.340.0230.04718.67
5.4.320.0080.05112.79
5.4.310.0100.04012.78
5.4.300.0070.03712.79
5.4.290.0070.04112.77
5.4.280.0080.04512.68
5.4.270.0070.03712.68
5.4.260.0080.04212.68
5.4.250.0090.04212.68
5.4.240.0130.04712.68
5.4.230.0060.04312.66
5.4.220.0090.03812.67
5.4.210.0100.03812.67
5.4.200.0130.04412.67
5.4.190.0130.04812.66
5.4.180.0220.04012.65
5.4.170.0420.07812.66
5.4.160.0140.04612.66
5.4.150.0110.04912.66
5.4.140.0190.04512.34
5.4.130.0140.04412.33
5.4.120.0130.04712.29
5.4.110.0120.05012.29
5.4.100.0170.04512.29
5.4.90.0240.06512.28
5.4.80.0120.04612.28
5.4.70.0100.04612.28
5.4.60.0160.04012.28
5.4.50.0180.03712.29
5.4.40.0130.04312.27
5.4.30.0200.03912.27
5.4.20.0330.08412.27
5.4.10.0120.04512.26
5.4.00.0140.04311.75
5.3.290.0070.05013.05
5.3.280.0030.04012.98
5.3.270.0140.04712.98
5.3.260.0200.07112.98
5.3.250.0140.04812.97
5.3.240.0180.04512.97
5.3.230.0150.04812.97
5.3.220.0280.06312.94
5.3.210.0210.03812.94
5.3.200.0150.04412.93
5.3.190.0190.04212.93
5.3.180.0180.04212.93
5.3.170.0370.08412.93
5.3.160.0210.04212.93
5.3.150.0170.04712.93
5.3.140.0140.04912.93
5.3.130.0160.04712.91
5.3.120.0220.04012.92
5.3.110.0160.04512.92
5.3.100.0190.04212.40
5.3.90.0170.04512.39
5.3.80.0110.05012.38
5.3.70.0140.04712.38
5.3.60.0200.04112.36
5.3.50.0210.04012.31
5.3.40.0170.06912.31
5.3.30.0130.04512.27
5.3.20.0180.04012.05
5.3.10.0300.05712.02
5.3.00.0140.04212.00
5.2.170.0140.0339.50
5.2.160.0120.0359.50
5.2.150.0110.0359.49
5.2.140.0180.0349.49
5.2.130.0290.0799.45
5.2.120.0110.0379.45
5.2.110.0170.0329.45
5.2.100.0140.0339.45
5.2.90.0240.0549.46
5.2.80.0150.0359.45
5.2.70.0090.0389.45
5.2.60.0070.0409.40
5.2.50.0330.0779.37
5.2.40.0140.0349.35
5.2.30.0150.0339.32
5.2.20.0140.0359.31
5.2.10.0130.0359.21
5.2.00.0180.0289.07
5.1.60.0090.0328.37
5.1.50.0230.0808.36
5.1.40.0100.0328.34
5.1.30.0100.0338.70
5.1.20.0160.0318.60
5.1.10.0090.0358.17
5.1.00.0120.0328.17
5.0.50.0120.0226.66
5.0.40.0090.0236.51
5.0.30.0090.0366.33
5.0.20.0270.0666.30
5.0.10.0050.0276.27
5.0.00.0100.0346.26
4.4.90.0080.0174.78
4.4.80.0060.0204.76
4.4.70.0060.0204.76
4.4.60.0060.0194.76
4.4.50.0070.0184.77
4.4.40.0070.0304.71
4.4.30.0040.0224.76
4.4.20.0100.0174.84
4.4.10.0070.0224.85
4.4.00.0080.0294.76
4.3.110.0060.0194.67
4.3.100.0110.0184.67
4.3.90.0080.0194.63
4.3.80.0040.0324.58
4.3.70.0100.0174.63
4.3.60.0210.0684.63
4.3.50.0020.0244.63
4.3.40.0180.0804.54
4.3.30.0060.0183.30
4.3.20.0040.0223.27
4.3.10.0050.0193.24
4.3.00.0070.01713.29

preferences:
52.72 ms | 400 KiB | 5 Q