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'][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.0130.00619.00
8.3.50.0170.00222.11
8.3.40.0130.00319.17
8.3.30.0120.00319.09
8.3.20.0100.00719.10
8.3.10.0050.00320.90
8.3.00.0000.00823.98
8.2.180.0120.00317.00
8.2.170.0100.00622.96
8.2.160.0120.00920.77
8.2.150.0050.00324.18
8.2.140.0140.00024.66
8.2.130.0110.00426.16
8.2.120.0080.00318.00
8.2.110.0060.00321.00
8.2.100.0090.00318.41
8.2.90.0000.00819.55
8.2.80.0030.00618.54
8.2.70.0030.00717.88
8.2.60.0030.00718.41
8.2.50.0030.00618.14
8.2.40.0000.00818.53
8.2.30.0050.00320.23
8.2.20.0040.00418.13
8.2.10.0000.00818.26
8.2.00.0050.00318.11
8.1.280.0140.00025.92
8.1.270.0030.00623.99
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0030.00622.98
8.1.230.0060.00621.37
8.1.220.0040.00418.77
8.1.210.0030.00519.18
8.1.200.0030.00817.85
8.1.190.0080.00017.98
8.1.180.0030.00518.32
8.1.170.0080.00019.16
8.1.160.0040.00419.29
8.1.150.0050.00319.10
8.1.140.0040.00417.80
8.1.130.0030.00318.19
8.1.120.0040.00417.68
8.1.110.0000.00717.84
8.1.100.0040.00417.87
8.1.90.0000.00817.88
8.1.80.0030.00517.95
8.1.70.0030.00317.82
8.1.60.0000.00918.02
8.1.50.0050.00317.92
8.1.40.0000.00917.91
8.1.30.0040.00417.97
8.1.20.0030.00618.11
8.1.10.0040.00418.03
8.1.00.0030.00518.02
8.0.300.0040.00420.40
8.0.290.0000.00717.55
8.0.280.0000.00718.82
8.0.270.0040.00417.63
8.0.260.0000.00717.28
8.0.250.0000.00817.36
8.0.240.0070.00317.26
8.0.230.0050.00317.21
8.0.220.0000.00717.20
8.0.210.0030.00317.21
8.0.200.0000.00817.37
8.0.190.0000.00717.31
8.0.180.0060.00317.26
8.0.170.0040.00417.34
8.0.160.0070.00017.19
8.0.150.0030.00517.21
8.0.140.0000.00717.29
8.0.130.0030.00313.78
8.0.120.0050.00217.30
8.0.110.0040.00417.21
8.0.100.0080.00017.18
8.0.90.0040.00417.25
8.0.80.0120.00417.31
8.0.70.0000.00717.23
8.0.60.0000.00717.39
8.0.50.0040.00417.26
8.0.30.0120.00917.65
8.0.20.0110.00817.43
8.0.10.0030.00517.41
8.0.00.0100.00717.32
7.4.330.0000.00615.16
7.4.320.0030.00316.98
7.4.300.0030.00316.97
7.4.290.0030.00316.96
7.4.280.0050.00317.04
7.4.270.0000.00716.88
7.4.260.0000.00613.65
7.4.250.0000.00716.89
7.4.240.0000.00717.05
7.4.230.0030.00317.03
7.4.220.0000.01817.04
7.4.210.0090.00817.07
7.4.200.0070.00017.09
7.4.190.0040.00416.80
7.4.160.0150.00617.04
7.4.150.0070.01017.40
7.4.140.0100.01117.86
7.4.130.0170.00016.92
7.4.120.0080.00916.94
7.4.110.0140.00316.92
7.4.100.0090.00916.84
7.4.90.0100.01016.89
7.4.80.0130.00319.37
7.4.70.0120.00917.00
7.4.60.0090.00816.87
7.4.50.0030.00616.93
7.4.40.0070.00722.27
7.4.30.0070.01416.94
7.4.10.0060.01315.34
7.4.00.0080.00815.26
7.3.330.0060.00013.66
7.3.320.0000.00513.52
7.3.310.0050.00316.68
7.3.300.0040.00416.80
7.3.290.0090.00916.82
7.3.280.0080.01016.78
7.3.270.0100.00717.40
7.3.260.0110.00718.24
7.3.250.0130.00916.91
7.3.240.0080.00816.85
7.3.230.0150.00317.09
7.3.210.0090.01516.98
7.3.200.0070.01019.39
7.3.190.0110.00617.08
7.3.180.0140.00317.02
7.3.170.0100.01016.79
7.3.160.0030.01316.84
7.3.130.0100.01014.87
7.3.120.0050.01215.17
7.3.110.0070.00714.73
7.3.100.0120.00615.36
7.3.90.0110.00315.00
7.3.80.0070.00615.02
7.3.70.0090.00615.13
7.3.60.0100.00715.31
7.3.50.0030.01415.03
7.3.40.0000.00915.28
7.3.30.0070.01015.05
7.3.20.0110.00417.01
7.3.10.0110.00016.78
7.3.00.0060.00916.97
7.2.330.0150.00417.29
7.2.320.0130.00316.96
7.2.310.0100.01316.91
7.2.300.0080.00817.08
7.2.290.0080.00817.13
7.2.260.0100.01015.44
7.2.250.0080.01215.50
7.2.240.0130.00315.11
7.2.230.0120.00615.44
7.2.220.0040.01415.46
7.2.210.0070.00714.93
7.2.200.0030.01315.34
7.2.190.0060.01215.42
7.2.180.0070.00715.32
7.2.170.0040.01215.30
7.2.160.0040.00815.30
7.2.150.0000.01517.02
7.2.140.0100.00717.05
7.2.130.0070.00317.10
7.2.120.0030.01317.07
7.2.110.0070.00317.29
7.2.100.0030.01617.21
7.2.90.0040.00817.33
7.2.80.0000.01017.16
7.2.70.0070.01117.50
7.2.60.0020.01217.14
7.2.50.0000.01017.22
7.2.40.0030.01017.09
7.2.30.0060.00917.25
7.2.20.0000.01017.00
7.2.10.0060.00617.48
7.2.00.0090.00618.21
7.1.330.0030.01216.01
7.1.320.0040.01116.14
7.1.310.0070.00716.03
7.1.300.0100.00616.07
7.1.290.0060.00715.96
7.1.280.0030.00916.09
7.1.270.0090.00315.82
7.1.260.0000.01316.00
7.1.250.0070.00315.93
7.1.240.0040.01116.03
7.1.230.0080.01116.05
7.1.220.0040.00816.02
7.1.210.0030.00916.13
7.1.200.0090.00416.07
7.1.190.0000.01816.28
7.1.180.0030.00715.79
7.1.170.0060.00616.12
7.1.160.0030.00915.97
7.1.150.0120.00415.79
7.1.140.0070.00716.06
7.1.130.0060.00616.01
7.1.120.0070.00716.09
7.1.110.0060.00316.13
7.1.100.0040.01017.34
7.1.90.0110.00415.98
7.1.80.0040.01116.06
7.1.70.0070.00416.85
7.1.60.0100.00617.76
7.1.50.0100.00716.31
7.1.40.0070.01016.34
7.1.30.0050.00515.89
7.1.20.0060.01116.18
7.1.10.0090.00916.08
7.1.00.0030.03819.26
7.0.330.0030.01015.75
7.0.320.0040.00815.95
7.0.310.0080.00615.65
7.0.300.0040.00415.74
7.0.290.0120.00315.39
7.0.280.0070.01015.54
7.0.270.0000.00815.48
7.0.260.0140.00015.89
7.0.250.0100.00315.61
7.0.240.0050.00515.56
7.0.230.0100.00315.41
7.0.220.0060.00915.70
7.0.210.0030.00915.52
7.0.200.0120.00715.38
7.0.190.0110.00415.50
7.0.180.0030.00915.67
7.0.170.0060.00615.65
7.0.160.0080.00415.71
7.0.150.0070.00715.59
7.0.140.0030.04018.85
7.0.130.0030.00915.80
7.0.120.0000.01515.88
7.0.110.0030.03018.81
7.0.100.0040.02718.75
7.0.90.0070.02018.78
7.0.80.0030.02518.81
7.0.70.0060.02418.75
7.0.60.0030.03818.77
7.0.50.0060.01819.09
7.0.40.0030.02516.99
7.0.30.0020.02416.90
7.0.20.0070.02216.92
7.0.10.0070.03816.83
7.0.00.0050.04717.02
5.6.400.0120.00314.63
5.6.390.0100.00714.67
5.6.380.0060.00614.58
5.6.370.0120.00314.38
5.6.360.0090.00314.89
5.6.350.0000.01714.61
5.6.340.0040.00414.26
5.6.330.0000.01514.67
5.6.320.0100.00314.71
5.6.310.0060.00314.97
5.6.300.0030.01314.92
5.6.290.0070.00714.40
5.6.280.0030.04117.96
5.6.270.0000.01314.73
5.6.260.0030.02517.56
5.6.250.0060.02117.72
5.6.240.0060.02017.62
5.6.230.0050.02217.87
5.6.220.0020.03017.76
5.6.210.0030.03017.62
5.6.200.0000.02617.86
5.6.190.0070.02217.91
5.6.180.0030.02518.02
5.6.170.0040.03217.86
5.6.160.0090.03517.78
5.6.150.0030.02217.96
5.6.140.0080.03517.90
5.6.130.0020.04817.82
5.6.120.0050.04818.14
5.6.110.0050.04417.79
5.6.100.0060.03818.00
5.6.90.0100.04017.77
5.6.80.0070.03917.58
5.6.70.0040.04117.63
5.6.60.0030.05017.67
5.6.50.0070.03817.66
5.6.40.0020.02917.56
5.6.30.0030.04517.60
5.6.20.0020.04617.45
5.6.10.0070.04217.46
5.6.00.0030.04217.41
5.5.380.0020.02517.68
5.5.370.0030.02417.64
5.5.360.0060.02217.57
5.5.350.0080.01817.65
5.5.340.0020.02517.83
5.5.330.0030.02617.86
5.5.320.0050.04217.85
5.5.310.0020.02917.86
5.5.300.0100.03717.86
5.5.290.0030.04517.87
5.5.280.0040.04217.84
5.5.270.0030.04917.86
5.5.260.0080.04017.83
5.5.250.0020.04817.68
5.5.240.0050.04417.41
5.5.230.0030.04617.47
5.5.220.0020.04217.33
5.5.210.0070.03817.56
5.5.200.0070.03817.54
5.5.190.0050.04417.36
5.5.180.0050.04217.53
5.5.170.0000.01314.61
5.5.160.0050.03917.48
5.5.150.0050.04217.48
5.5.140.0030.04317.38
5.5.130.0080.04217.47
5.5.120.0050.03617.46
5.5.110.0100.03817.38
5.5.100.0080.04017.30
5.5.90.0120.03417.52
5.5.80.0070.04017.18
5.5.70.0070.03817.31
5.5.60.0030.04517.44
5.5.50.0020.04417.22
5.5.40.0080.03017.51
5.5.30.0060.04417.37
5.5.20.0030.04317.29
5.5.10.0090.03517.22
5.5.00.0030.04317.36
5.4.450.0050.03515.96
5.4.440.0120.02815.88
5.4.430.0030.04015.79
5.4.420.0030.04115.81
5.4.410.0080.03315.88
5.4.400.0040.03815.78
5.4.390.0030.04515.70
5.4.380.0030.04015.62
5.4.370.0030.03815.70
5.4.360.0070.03815.81
5.4.350.0040.04015.62
5.4.340.0050.03815.70
5.4.330.0030.00512.09
5.4.320.0030.03015.83
5.4.310.0050.03515.81
5.4.300.0010.04415.77
5.4.290.0030.04015.69
5.4.280.0030.04115.66
5.4.270.0020.04315.65
5.4.260.0040.04415.68
5.4.250.0090.03515.60
5.4.240.0040.04015.83
5.4.230.0000.04315.71
5.4.220.0050.03815.70
5.4.210.0000.04115.63
5.4.200.0050.02315.81
5.4.190.0020.04315.72
5.4.180.0070.02215.62
5.4.170.0030.03715.62
5.4.160.0030.03915.71
5.4.150.0000.02915.77
5.4.140.0080.02214.30
5.4.130.0020.03614.29
5.4.120.0060.03814.40
5.4.110.0030.03914.47
5.4.100.0050.04014.49
5.4.90.0000.04414.34
5.4.80.0060.03514.41
5.4.70.0040.03914.41
5.4.60.0050.03514.35
5.4.50.0060.03414.46
5.4.40.0030.03714.46
5.4.30.0050.03714.47
5.4.20.0030.04214.43
5.4.10.0070.03514.33
5.4.00.0000.04314.18
5.3.290.0020.03713.57
5.3.280.0050.02313.52
5.3.270.0040.04213.48
5.3.260.0060.03613.43
5.3.250.0030.03813.45
5.3.240.0080.03713.51
5.3.230.0030.02713.48
5.3.220.0020.03813.46
5.3.210.0060.03713.49
5.3.200.0030.04013.47
5.3.190.0050.04113.46
5.3.180.0030.04013.49
5.3.170.0060.04013.48
5.3.160.0030.04113.42
5.3.150.0020.04013.49
5.3.140.0030.03713.41
5.3.130.0030.04113.45
5.3.120.0040.03913.41
5.3.110.0050.04013.51
5.3.100.0030.04113.25
5.3.90.0020.04113.15
5.3.80.0030.03813.14
5.3.70.0030.02813.19
5.3.60.0030.03513.14
5.3.50.0030.03813.18
5.3.40.0080.03313.11
5.3.30.0040.04013.16
5.3.20.0010.03912.97
5.3.10.0020.03612.97
5.3.00.0020.03713.02
5.2.170.0070.05713.46
5.2.160.0030.03713.46
5.2.150.0030.03713.46
5.2.140.0000.04013.46
5.2.130.0000.06313.46
5.2.120.0000.05713.46
5.2.110.0030.05713.46
5.2.100.0030.06013.46
5.2.90.0070.05013.46
5.2.80.0100.05713.46
5.2.70.0070.06013.46
5.2.60.0030.05713.46
5.2.50.0030.06313.46
5.2.40.0030.06013.46
5.2.30.0100.05713.46
5.2.20.0000.06313.46
5.2.10.0030.05713.46
5.2.00.0070.03713.46
5.1.60.0000.06013.46
5.1.50.0030.05313.46
5.1.40.0000.05013.46
5.1.30.0030.05313.46
5.1.20.0070.05313.46
5.1.10.0030.05713.46
5.1.00.0070.05013.46
5.0.50.0000.04713.46
5.0.40.0000.04713.46
5.0.30.0070.06713.46
5.0.20.0000.04313.46
5.0.10.0030.04713.46
5.0.00.0000.06713.46
4.4.90.0000.03313.46
4.4.80.0030.03313.46
4.4.70.0100.02713.46
4.4.60.0000.03713.46
4.4.50.0000.03313.46
4.4.40.0070.04713.46
4.4.30.0000.02713.46
4.4.20.0030.03713.46
4.4.10.0000.03713.46
4.4.00.0030.05313.46
4.3.110.0000.02313.46
4.3.100.0030.03313.46
4.3.90.0030.03013.46
4.3.80.0030.05013.46
4.3.70.0000.03313.46
4.3.60.0030.03013.46
4.3.50.0000.03713.46
4.3.40.0100.04313.46
4.3.30.0000.03713.46
4.3.20.0000.03713.46
4.3.10.0000.03713.46
4.3.00.0070.01313.46

preferences:
45.2 ms | 400 KiB | 5 Q