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 (preg_match('/(\w+)\[(\d+)\]/', $offset, $nodes)) { $node = $nodes[1]; $key = $nodes[2]; return new self($this->xml->$node[$key]->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']; $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.01217.38
8.3.50.0100.01122.24
8.3.40.0150.00719.29
8.3.30.0120.00419.42
8.3.20.0040.00420.45
8.3.10.0040.00423.76
8.3.00.0040.00419.76
8.2.180.0150.00618.92
8.2.170.0100.00722.96
8.2.160.0080.00620.80
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.01126.16
8.2.120.0040.01122.45
8.2.110.0070.00422.45
8.2.100.0090.00318.41
8.2.90.0040.00419.59
8.2.80.0080.00018.30
8.2.70.0030.00618.25
8.2.60.0000.00818.42
8.2.50.0000.01218.25
8.2.40.0060.00318.47
8.2.30.0090.00018.35
8.2.20.0040.00418.25
8.2.10.0030.00618.45
8.2.00.0000.00918.31
8.1.280.0090.01225.92
8.1.270.0060.00324.39
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00324.21
8.1.230.0080.00419.19
8.1.220.0030.00617.78
8.1.210.0000.00818.77
8.1.200.0070.00317.98
8.1.190.0080.00017.90
8.1.180.0030.00618.10
8.1.170.0030.00519.15
8.1.160.0050.00222.34
8.1.150.0080.00019.09
8.1.140.0080.00017.96
8.1.130.0070.00018.14
8.1.120.0070.00017.91
8.1.110.0040.00417.82
8.1.100.0040.00417.93
8.1.90.0020.00517.79
8.1.80.0000.00717.89
8.1.70.0040.00417.79
8.1.60.0080.00318.07
8.1.50.0030.00617.87
8.1.40.0000.00817.93
8.1.30.0030.00518.07
8.1.20.0030.00517.99
8.1.10.0030.00518.05
8.1.00.0050.00317.82
8.0.300.0040.00418.77
8.0.290.0040.00417.55
8.0.280.0000.00718.78
8.0.270.0040.00417.32
8.0.260.0000.00817.35
8.0.250.0030.00617.36
8.0.240.0000.00817.44
8.0.230.0060.00317.48
8.0.220.0030.00317.45
8.0.210.0070.00017.43
8.0.200.0030.00317.42
8.0.190.0040.00417.55
8.0.180.0040.00417.43
8.0.170.0090.00017.32
8.0.160.0000.00717.42
8.0.150.0070.00017.29
8.0.140.0000.00817.19
8.0.130.0000.00613.87
8.0.120.0030.00617.39
8.0.110.0040.00417.31
8.0.100.0070.00017.42
8.0.90.0020.00517.42
8.0.80.0070.00717.38
8.0.70.0040.00417.47
8.0.60.0040.00417.47
8.0.50.0040.00417.40
8.0.30.0100.01317.63
8.0.20.0100.00917.65
8.0.10.0000.00817.31
8.0.00.0060.01117.08
7.4.330.0050.00015.34
7.4.320.0030.00317.11
7.4.300.0000.00717.15
7.4.290.0040.00716.95
7.4.280.0070.00017.12
7.4.270.0050.00316.95
7.4.260.0070.00316.99
7.4.250.0040.00416.98
7.4.240.0060.00217.07
7.4.230.0050.00317.05
7.4.220.0070.01117.23
7.4.210.0090.00917.10
7.4.200.0050.00217.11
7.4.190.0040.00417.25
7.4.160.0120.01217.12
7.4.150.0090.00917.40
7.4.140.0080.01117.86
7.4.130.0140.00317.14
7.4.120.0120.00716.89
7.4.110.0100.00917.00
7.4.100.0060.01216.89
7.4.90.0180.01116.95
7.4.80.0000.01919.39
7.4.70.0070.01017.01
7.4.60.0100.01017.01
7.4.50.0000.00717.07
7.4.40.0100.00222.77
7.4.30.0120.00616.96
7.4.00.0150.00015.32
7.3.330.0000.00613.80
7.3.320.0000.00513.80
7.3.310.0080.00016.71
7.3.300.0000.00716.91
7.3.290.0040.01116.87
7.3.280.0070.00916.84
7.3.270.0030.01517.40
7.3.260.0090.00916.97
7.3.250.0090.01516.81
7.3.240.0130.00316.88
7.3.230.0030.01316.90
7.3.210.0090.01317.00
7.3.200.0160.00619.39
7.3.190.0090.00916.90
7.3.180.0060.01017.10
7.3.170.0090.00616.84
7.3.160.0140.00316.97
7.3.120.0070.01015.32
7.2.330.0060.01317.08
7.2.320.0100.00717.21
7.2.310.0100.00717.22
7.2.300.0130.01017.12
7.2.290.0060.01017.23
7.2.110.0170.00716.86
7.2.100.0030.00716.93
7.2.90.0030.01016.82
7.2.80.0100.00317.02
7.2.70.0030.01017.15
7.2.60.0100.00517.29
7.2.50.0030.01317.03
7.2.40.0070.01417.23
7.2.30.0110.01117.40
7.2.20.0150.00316.93
7.2.10.0060.00617.14
7.2.00.0080.00618.48
7.1.230.0060.00616.14
7.1.220.0070.00716.04
7.1.210.0110.00715.94
7.1.200.0090.00715.93
7.1.190.0000.01316.08
7.1.180.0100.00716.13
7.1.170.0100.01015.91
7.1.160.0100.01016.04
7.1.150.0090.00615.97
7.1.140.0130.00715.88
7.1.130.0070.01115.79
7.1.120.0160.00316.04
7.1.110.0150.00716.05
7.1.100.0050.01017.20
7.1.90.0030.00715.98
7.1.80.0080.00415.84
7.1.70.0070.00416.61
7.1.60.0090.00917.68
7.1.50.0110.01016.48
7.1.40.0120.00416.02
7.1.30.0120.00715.94
7.1.20.0160.00716.02
7.1.10.0030.01315.88
7.1.00.0080.04219.12
7.0.310.0040.00415.59
7.0.300.0040.01115.88
7.0.290.0090.00615.61
7.0.280.0070.00415.67
7.0.270.0070.00715.49
7.0.260.0030.00915.62
7.0.250.0040.01115.37
7.0.240.0000.01315.71
7.0.230.0130.00315.64
7.0.220.0030.01015.53
7.0.210.0070.00715.53
7.0.200.0060.01016.40
7.0.190.0100.00315.44
7.0.180.0100.00815.64
7.0.170.0140.00315.49
7.0.160.0110.00415.41
7.0.150.0170.00315.50
7.0.140.0060.04018.76
7.0.130.0100.01015.57
7.0.120.0030.00815.55
7.0.110.0090.00915.34
7.0.100.0060.00615.53
7.0.90.0120.00315.53
7.0.80.0090.00615.52
7.0.70.0030.00815.70
7.0.60.0050.04717.79
7.0.50.0090.04116.80
7.0.40.0090.02516.81
7.0.30.0210.04316.86
7.0.20.0160.02016.92
7.0.10.0120.02316.86
7.0.00.0070.04716.77
5.6.380.0060.00314.50
5.6.370.0060.01014.72
5.6.360.0080.00814.75
5.6.350.0000.01714.64
5.6.340.0000.01414.37
5.6.330.0080.00814.43
5.6.320.0000.01414.70
5.6.310.0110.00714.14
5.6.300.0000.01314.47
5.6.290.0040.00814.25
5.6.280.0030.04217.68
5.6.270.0060.01314.65
5.6.260.0030.01314.48
5.6.250.0030.00714.48
5.6.240.0030.00614.46
5.6.230.0050.00914.42
5.6.220.0060.00914.63
5.6.210.0050.04217.56
5.6.200.0070.04216.42
5.6.190.0060.03017.36
5.6.180.0040.02817.49
5.6.170.0180.02617.49
5.6.160.0100.02517.43
5.6.150.0150.04016.31
5.6.140.0080.02316.30
5.6.130.0060.02616.25
5.6.120.0100.02117.77
5.6.110.0130.04317.77
5.6.100.0120.02117.71
5.6.90.0180.03917.75
5.6.80.0200.03717.31
5.6.70.1380.02317.34
5.6.60.0040.01714.05
5.6.50.0120.00814.25
5.6.40.0080.00814.20
5.6.30.0100.01014.31
5.6.20.0100.01014.37
5.6.10.0140.00713.95
5.6.00.0140.00914.52
5.5.380.0000.00811.29
5.5.370.0130.00010.92
5.5.360.0080.00511.21
5.5.350.0070.04016.02
5.5.340.0050.04514.57
5.5.330.0060.02315.94
5.5.320.0220.03915.97
5.5.310.0140.02715.86
5.5.300.0030.02914.80
5.5.290.0120.04014.67
5.5.280.0070.04516.01
5.5.270.0130.03316.00
5.5.260.0110.03916.04
5.5.250.0080.02315.94
5.5.240.0100.04315.74
5.5.230.0040.01111.04
5.5.220.0080.00811.26
5.5.210.0030.01011.04
5.5.200.0080.00611.12
5.5.190.0040.01111.21
5.5.180.0060.00610.97
5.5.170.0140.00614.09
5.5.160.0030.01011.24
5.5.150.0090.00511.42
5.5.140.0050.01010.94
5.5.130.0070.00711.06
5.5.120.0110.00011.27
5.5.110.0040.00710.98
5.5.100.0090.00611.02
5.5.90.0070.00410.97
5.5.80.0080.00411.14
5.5.70.0040.00810.85
5.5.60.0110.00311.21
5.5.50.0040.01210.98
5.5.40.0080.00810.92
5.5.30.0000.01611.47
5.5.20.0000.01411.19
5.5.10.0110.00311.20
5.5.00.0160.00011.35
5.4.450.0050.03615.38
5.4.440.0340.03415.26
5.4.430.0400.03315.22
5.4.420.0270.03215.26
5.4.410.0260.02715.16
5.4.400.0420.02615.10
5.4.390.0400.02415.04
5.4.380.0140.03414.79
5.4.370.0220.02514.84
5.4.360.0180.02714.86
5.4.350.0160.03515.05
5.4.340.0170.03015.00
5.4.330.0080.00310.79
5.4.320.0060.02611.79
5.4.310.0070.02311.86
5.4.300.0110.02011.93
5.4.290.0040.02611.88
5.4.280.0070.02111.75
5.4.270.0100.01811.64
5.4.260.0070.02111.84
5.4.250.0050.02411.71
5.4.240.0040.02511.69
5.4.230.0050.02511.71
5.4.220.0040.02411.81
5.4.210.0080.01911.73
5.4.200.0100.02011.81
5.4.190.0110.02611.83
5.4.180.0070.02911.76
5.4.170.0070.02811.80
5.4.160.0080.03011.72
5.4.150.0120.02511.76
5.4.140.0150.02111.69
5.4.130.0110.02611.53
5.4.120.0100.02611.55
5.4.110.0090.02611.66
5.4.100.0070.02811.66
5.4.90.0110.02411.63
5.4.80.0140.02211.63
5.4.70.0100.02611.71
5.4.60.0110.02311.56
5.4.50.0080.02611.54
5.4.40.0110.02411.75
5.4.30.0150.02111.74
5.4.20.0150.02011.49
5.4.10.0130.02311.65
5.4.00.0150.02011.29
5.3.290.0080.02211.88
5.3.280.0060.02211.86
5.3.270.0130.02311.88
5.3.260.0100.02511.85
5.3.250.0130.02411.92
5.3.240.0140.02611.79
5.3.230.0140.02811.81
5.3.220.0100.02611.83
5.3.210.0170.01911.84
5.3.200.0120.02311.84
5.3.190.0090.02711.80
5.3.180.0130.02511.90
5.3.170.0110.04011.85
5.3.160.0110.02511.90
5.3.150.0100.02811.89
5.3.140.0230.04811.82
5.3.130.0170.05311.82
5.3.120.0220.03511.82
5.3.110.0130.02811.83
5.3.100.0110.02711.52
5.3.90.0180.03611.63
5.3.80.0160.02111.53
5.3.70.0120.02711.41
5.3.60.0120.02711.41
5.3.50.0120.02511.51
5.3.40.0130.02411.47
5.3.30.0100.02511.43
5.3.20.0110.02411.31
5.3.10.0180.04711.19
5.3.00.0080.02811.22
5.2.170.0100.0219.54
5.2.160.0100.0199.48
5.2.150.0120.0199.57
5.2.140.0120.0189.45
5.2.130.0160.0289.48
5.2.120.0100.0199.47
5.2.110.0080.0229.49
5.2.100.0080.0229.58
5.2.90.0130.0169.49
5.2.80.0070.0229.49
5.2.70.0090.0199.38
5.2.60.0130.0159.41
5.2.50.0090.0209.46
5.2.40.0050.0259.42
5.2.30.0170.0409.44
5.2.20.0100.0189.33
5.2.10.0100.0199.22
5.2.00.0070.0219.13
5.1.60.0070.0198.51
5.1.50.0050.0198.51
5.1.40.0090.0168.52
5.1.30.0120.0148.67
5.1.20.0090.0198.77
5.1.10.0070.0188.45
5.1.00.0060.0198.45
5.0.50.0030.0187.69
5.0.40.0060.0147.62
5.0.30.0080.0207.53
5.0.20.0050.0137.51
5.0.10.0080.0277.50
5.0.00.0080.0187.50
4.4.90.0060.0116.75
4.4.80.0040.0126.74
4.4.70.0040.0136.74
4.4.60.0050.0106.74
4.4.50.0100.0216.75
4.4.40.0020.0196.72
4.4.30.0060.0106.75
4.4.20.0080.0076.79
4.4.10.0060.0106.79
4.4.00.0040.0176.74
4.3.110.0050.0106.70
4.3.100.0040.0116.70
4.3.90.0050.0106.68
4.3.80.0110.0266.66
4.3.70.0060.0096.68
4.3.60.0040.0116.68
4.3.50.0050.0106.68
4.3.40.0050.0136.63
4.3.30.0030.0116.02
4.3.20.0050.0106.00
4.3.10.0050.0095.99
4.3.00.0030.0128.28

preferences:
41.27 ms | 401 KiB | 5 Q