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); } if ('val1' == $offset) { var_dump((array)$this->xml->$offset);die; } var_dump((array) $this->xml->$offset); return (array) $this->xml->$offset;//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'];

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.0150.00417.00
8.3.50.0060.00917.58
8.3.40.0110.00719.09
8.3.30.0040.01119.00
8.3.20.0000.00819.02
8.3.10.0030.00620.52
8.3.00.0080.00017.88
8.2.180.0130.00917.00
8.2.170.0120.00322.96
8.2.160.0070.00722.38
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.14
8.2.110.0110.00021.13
8.2.100.0090.00318.06
8.2.90.0040.00419.41
8.2.80.0000.00818.29
8.2.70.0030.00517.88
8.2.60.0060.00318.18
8.2.50.0030.00518.07
8.2.40.0030.00618.28
8.2.30.0050.00318.37
8.2.20.0000.00817.84
8.2.10.0080.00019.78
8.2.00.0060.00317.91
8.1.280.0000.01825.92
8.1.270.0030.00624.66
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0100.00722.54
8.1.230.0000.01221.13
8.1.220.0040.00418.77
8.1.210.0000.00819.12
8.1.200.0030.00717.73
8.1.190.0000.00917.68
8.1.180.0000.00918.10
8.1.170.0000.00818.75
8.1.160.0040.00419.10
8.1.150.0000.00818.71
8.1.140.0000.00817.63
8.1.130.0030.00317.69
8.1.120.0040.00417.71
8.1.110.0000.00717.77
8.1.100.0000.00717.61
8.1.90.0040.00417.73
8.1.80.0000.00817.52
8.1.70.0030.00317.70
8.1.60.0000.00717.71
8.1.50.0040.00417.77
8.1.40.0040.00417.77
8.1.30.0040.00417.86
8.1.20.0030.00617.79
8.1.10.0030.00617.82
8.1.00.0030.00517.75
8.0.300.0040.00420.14
8.0.290.0040.00417.00
8.0.280.0070.00018.72
8.0.270.0070.00017.39
8.0.260.0040.00417.11
8.0.250.0040.00417.23
8.0.240.0030.00517.13
8.0.230.0030.00517.14
8.0.220.0030.00517.14
8.0.210.0000.00717.10
8.0.200.0040.00417.10
8.0.190.0070.00017.32
8.0.180.0040.00417.24
8.0.170.0040.00417.08
8.0.160.0020.00517.22
8.0.150.0100.00017.13
8.0.140.0110.00017.16
8.0.130.0070.00013.61
8.0.120.0080.00017.02
8.0.110.0040.00417.24
8.0.100.0000.00717.19
8.0.90.0040.00417.11
8.0.80.0030.01717.17
8.0.70.0030.00517.23
8.0.60.0040.00417.08
8.0.50.0040.00417.23
8.0.30.0100.01117.31
8.0.20.0150.00817.35
8.0.10.0070.00017.18
8.0.00.0130.00516.91
7.4.330.0050.00013.21
7.4.320.0000.00716.69
7.4.300.0070.00016.84
7.4.290.0030.00316.86
7.4.280.0000.00916.75
7.4.270.0080.00016.87
7.4.260.0000.00513.37
7.4.250.0090.00016.83
7.4.240.0030.00316.78
7.4.230.0000.00816.82
7.4.220.0070.01016.68
7.4.210.0040.01016.83
7.4.200.0000.00716.81
7.4.190.0000.00716.93
7.4.160.0060.00916.74
7.4.150.0100.01316.70
7.4.140.0060.01516.71
7.4.130.0050.01416.87
7.4.120.0110.00716.58
7.4.110.0170.00016.75
7.4.100.0120.00916.80
7.4.90.0070.01116.78
7.4.80.0110.00516.71
7.4.70.0120.00616.88
7.4.60.0030.01316.68
7.4.50.0000.00816.91
7.4.40.0090.00616.72
7.4.30.0090.01516.87
7.4.00.0070.01115.13
7.3.330.0030.00313.53
7.3.320.0060.00013.58
7.3.310.0030.00316.52
7.3.300.0070.00016.53
7.3.290.0120.00316.68
7.3.280.0090.01116.63
7.3.270.0120.00416.86
7.3.260.0120.00616.66
7.3.250.0130.00816.73
7.3.240.0060.01216.65
7.3.230.0100.00716.68
7.3.210.0070.01016.66
7.3.200.0100.00719.39
7.3.190.0060.00316.78
7.3.180.0100.00716.77
7.3.170.0070.01016.66
7.3.160.0080.00816.74
7.3.120.0090.00715.11
7.3.110.0110.00715.10
7.3.100.0150.00015.02
7.3.90.0070.01114.94
7.3.80.0100.00614.89
7.3.70.0080.00415.02
7.3.60.0000.01215.00
7.3.50.0080.00615.02
7.3.40.0030.01015.05
7.3.30.0060.00914.91
7.3.20.0060.00616.81
7.3.10.0060.00616.79
7.3.00.0050.00516.80
7.2.330.0120.00617.03
7.2.320.0110.00716.78
7.2.310.0060.01517.09
7.2.300.0080.00817.02
7.2.290.0170.00016.79
7.2.250.0090.00915.36
7.2.240.0100.00715.17
7.2.230.0090.00915.01
7.2.220.0070.00715.41
7.2.210.0070.00715.17
7.2.200.0000.01715.13
7.2.190.0000.01615.15
7.2.180.0060.00615.23
7.2.170.0090.00915.15
7.2.60.0040.00716.87
7.2.50.0140.00017.21
7.1.330.0150.00016.00
7.1.320.0110.00315.94
7.1.310.0030.00916.26
7.1.300.0000.01315.96
7.1.290.0070.00715.77
7.1.280.0080.00816.07
7.1.270.0000.01216.10
7.1.260.0030.00615.80
7.1.200.0060.00315.84
7.1.70.0040.01117.30
7.1.60.0070.01719.40
7.1.50.0000.02116.87
7.1.00.0130.06722.55
7.0.200.0000.00716.87
7.0.140.0070.07022.20
7.0.120.0030.05322.13
7.0.60.0030.08320.20
7.0.50.0070.08717.98
7.0.40.0070.08717.86
7.0.30.0100.07317.89
7.0.20.0070.08017.89
7.0.10.0170.07317.88
7.0.00.0130.04317.91
5.6.280.0030.07721.00
5.6.210.0200.07020.68
5.6.200.0170.05718.38
5.6.190.0070.08318.20
5.6.180.0070.08018.20
5.6.170.0100.06318.19
5.6.160.0070.07318.23
5.6.150.0170.04018.23
5.6.140.0000.08718.29
5.6.130.0030.04718.25
5.6.120.0070.07718.32
5.6.110.0070.04318.31
5.6.100.0100.07718.31
5.6.90.0100.06018.26
5.6.80.0070.05717.65
5.6.70.0070.03717.63
5.6.60.0130.06017.68
5.6.50.0030.08017.64
5.6.40.0070.04717.77
5.6.30.0030.08317.64
5.6.20.0070.08017.60
5.6.10.0030.05717.67
5.6.00.0100.04717.53
5.5.350.0030.08320.52
5.5.340.0000.05018.21
5.5.330.0100.06318.03
5.5.320.0130.07318.12
5.5.310.0070.08318.15
5.5.300.0030.07018.17
5.5.290.0130.05318.15
5.5.280.0070.04018.17
5.5.270.0070.06317.98
5.5.260.0000.09018.08
5.5.250.0130.07317.97
5.5.240.0070.05017.45
5.5.230.0070.06317.53
5.5.220.0070.07717.50
5.5.210.0070.07717.59
5.5.200.0070.03717.46
5.5.190.0070.06717.38
5.5.180.0030.07317.57
5.5.160.0030.08017.46
5.5.150.0130.07317.43
5.5.140.0030.05017.51
5.5.130.0030.06017.40
5.5.120.0100.04017.51
5.5.110.0100.05317.40
5.5.100.0070.08017.28
5.5.90.0100.06017.27
5.5.80.0030.05017.27
5.5.70.0030.05717.36
5.5.60.0100.07317.45
5.5.50.0070.03317.37
5.5.40.0030.05717.32
5.5.30.0000.04017.27
5.5.20.0070.04317.27
5.5.10.0100.03717.39
5.5.00.0000.05317.25
5.4.450.0030.07319.38
5.4.440.0100.03719.48
5.4.430.0030.05319.55
5.4.420.0130.07319.58
5.4.410.0100.05319.16
5.4.400.0130.04319.25
5.4.390.0030.07719.12
5.4.380.0030.06718.96
5.4.370.0100.04719.21
5.4.360.0130.04719.20
5.4.350.0100.07719.05
5.4.340.0100.07719.11
5.4.320.0130.04319.27
5.4.310.0070.07719.17
5.4.300.0100.04019.21
5.4.290.0070.05319.18
5.4.280.0000.05319.19
5.4.270.0170.06719.11
5.4.260.0070.04719.26
5.4.250.0130.07319.25
5.4.240.0100.04319.11
5.4.230.0100.06719.18
5.4.220.0100.03719.18
5.4.210.0100.03319.13
5.4.200.0170.06719.18
5.4.190.0030.04718.95
5.4.180.0030.06019.19
5.4.170.0000.04719.20
5.4.160.0100.04319.09
5.4.150.0070.06019.09
5.4.140.0070.04316.56
5.4.130.0100.06716.52
5.4.120.0070.05016.55
5.4.110.0100.07016.55
5.4.100.0070.05016.59
5.4.90.0070.07016.54
5.4.80.0130.05316.52
5.4.70.0000.07716.46
5.4.60.0100.03316.48
5.4.50.0130.06016.50
5.4.40.0000.04016.45
5.4.30.0070.05716.52
5.4.20.0170.03716.49
5.4.10.0100.07316.63
5.4.00.0030.07015.97
5.3.290.0070.07714.80
5.3.280.0030.08314.75
5.3.270.0070.05014.73
5.3.260.0300.03314.77
5.3.250.0070.05714.78
5.3.240.0070.04714.70
5.3.230.0000.08314.86
5.3.220.0100.04714.73
5.3.210.0070.05014.74
5.3.200.0070.07714.87
5.3.190.0100.04014.57
5.3.180.0000.05014.69
5.3.170.0030.08014.70
5.3.160.0030.04314.73
5.3.150.0200.06314.71
5.3.140.0070.04014.70
5.3.130.0030.05014.60
5.3.120.0100.05714.51
5.3.110.0070.04714.66
5.3.100.0030.04314.19
5.3.90.0070.03714.18
5.3.80.0070.04014.09
5.3.70.0100.06714.18
5.3.60.0030.05313.99
5.3.50.0070.07314.04
5.3.40.0030.05014.10
5.3.30.0070.05013.93
5.3.20.0030.04313.82
5.3.10.0070.07013.81
5.3.00.0170.06313.79
5.2.170.0000.06311.14
5.2.160.0030.03711.29
5.2.150.0100.05711.27
5.2.140.0000.04311.26
5.2.130.0070.05311.23
5.2.120.0030.03711.22
5.2.110.0100.04011.10
5.2.100.0070.06011.25
5.2.90.0130.05311.18
5.2.80.0070.05311.34
5.2.70.0100.04711.21
5.2.60.0000.06011.13
5.2.50.0100.06011.14
5.2.40.0030.05011.21
5.2.30.0070.05710.97
5.2.20.0130.04311.09
5.2.10.0070.04011.13
5.2.00.0100.04310.85
5.1.60.0100.05010.18
5.1.50.0070.04710.18
5.1.40.0070.0339.98
5.1.30.0000.05710.49
5.1.20.0030.03310.50
5.1.10.0030.05010.14
5.1.00.0000.04310.14
5.0.50.0000.0238.61
5.0.40.0070.0238.50
5.0.30.0000.0538.24
5.0.20.0070.0408.28
5.0.10.0100.0408.24
5.0.00.0030.0538.15
4.4.90.0000.0407.84
4.4.80.0030.0277.84
4.4.70.0030.0337.84
4.4.60.0000.0337.84
4.4.50.0000.0277.84
4.4.40.0030.0537.84
4.4.30.0030.0277.84
4.4.20.0000.0377.84
4.4.10.0000.0207.84
4.4.00.0070.0237.84
4.3.110.0030.0137.84
4.3.100.0030.0337.84
4.3.90.0030.0277.84
4.3.80.0000.0507.84
4.3.70.0030.0337.84
4.3.60.0030.0337.84
4.3.50.0070.0307.84
4.3.40.0000.0407.84
4.3.30.0000.0337.84
4.3.20.0030.0307.84
4.3.10.0000.0337.84
4.3.00.0000.0377.84

preferences:
40.27 ms | 401 KiB | 5 Q