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)) { return new self($this->xml[$offset]->asXML(), false); } var_dump($this->xml->$offset->asXML()); 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']; var_dump($xml->getIterator()->recursive);

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.0070.01417.13
8.3.50.0130.00516.84
8.3.40.0000.01419.09
8.3.30.0140.00018.99
8.3.20.0040.00419.03
8.3.10.0050.00320.79
8.3.00.0090.00017.50
8.2.180.0090.01318.84
8.2.170.0110.01122.96
8.2.160.0060.00922.15
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0050.00220.08
8.2.110.0070.00421.24
8.2.100.0120.00017.97
8.2.90.0030.00519.47
8.2.80.0050.00318.05
8.2.70.0050.00317.49
8.2.60.0030.00618.04
8.2.50.0040.00418.07
8.2.40.0040.00418.34
8.2.30.0000.00718.14
8.2.20.0040.00417.91
8.2.10.0000.00817.97
8.2.00.0040.00418.10
8.1.280.0100.01025.92
8.1.270.0000.00824.66
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0000.00922.78
8.1.230.0080.00421.26
8.1.220.0030.00618.77
8.1.210.0050.00319.14
8.1.200.0030.00717.50
8.1.190.0040.00417.91
8.1.180.0040.00418.10
8.1.170.0070.00319.09
8.1.160.0040.00419.03
8.1.150.0050.00218.87
8.1.140.0000.00717.68
8.1.130.0070.00018.09
8.1.120.0050.00217.63
8.1.110.0050.00317.67
8.1.100.0000.00717.57
8.1.90.0040.00417.68
8.1.80.0000.00817.74
8.1.70.0040.00417.68
8.1.60.0030.00517.72
8.1.50.0040.00417.75
8.1.40.0090.00017.78
8.1.30.0040.00417.77
8.1.20.0040.00417.80
8.1.10.0050.00217.79
8.1.00.0040.00417.74
8.0.300.0050.00520.04
8.0.290.0000.00716.75
8.0.280.0000.00718.66
8.0.270.0000.00717.34
8.0.260.0040.00416.89
8.0.250.0000.00817.05
8.0.240.0060.00317.11
8.0.230.0000.00717.11
8.0.220.0000.00717.19
8.0.210.0030.00317.05
8.0.200.0040.00417.13
8.0.190.0040.00417.10
8.0.180.0040.00417.11
8.0.170.0040.00417.07
8.0.160.0070.00017.13
8.0.150.0080.00016.96
8.0.140.0070.00317.13
8.0.130.0000.00613.55
8.0.120.0040.00417.05
8.0.110.0030.00616.96
8.0.100.0070.00016.93
8.0.90.0050.00217.20
8.0.80.0060.01817.11
8.0.70.0030.00616.89
8.0.60.0070.00017.16
8.0.50.0040.00417.20
8.0.30.0140.00917.34
8.0.20.0120.00617.20
8.0.10.0040.00417.11
8.0.00.0070.01117.11
7.4.330.0000.00513.17
7.4.320.0040.00416.69
7.4.300.0060.00016.60
7.4.290.0040.00416.79
7.4.280.0030.00616.71
7.4.270.0030.00316.68
7.4.260.0000.00513.46
7.4.250.0000.00916.71
7.4.240.0080.00016.88
7.4.230.0000.00716.61
7.4.220.0180.02116.93
7.4.210.0090.01016.82
7.4.200.0070.00016.78
7.4.190.0070.00016.67
7.4.160.0060.01016.60
7.4.150.0080.01216.65
7.4.140.0120.00916.72
7.4.130.0100.00816.95
7.4.120.0080.01016.87
7.4.110.0030.01516.84
7.4.100.0110.00816.70
7.4.90.0220.00316.89
7.4.80.0120.00616.44
7.4.70.0160.00016.56
7.4.60.0090.00916.76
7.4.50.0030.00316.39
7.4.40.0070.00716.62
7.4.30.0170.00516.68
7.4.00.0080.00915.00
7.3.330.0050.00213.50
7.3.320.0000.00613.50
7.3.310.0050.00316.37
7.3.300.0030.00316.33
7.3.290.0060.00916.54
7.3.280.0090.00716.51
7.3.270.0110.00616.54
7.3.260.0100.00916.54
7.3.250.0140.00816.49
7.3.240.0100.00616.81
7.3.230.0000.01816.70
7.3.210.0180.00016.71
7.3.200.0050.01319.39
7.3.190.0040.00716.64
7.3.180.0070.00916.49
7.3.170.0070.01016.61
7.3.160.0100.00716.65
7.3.120.0070.00614.72
7.3.110.0100.00314.79
7.3.100.0080.00814.80
7.3.90.0040.01415.08
7.3.80.0090.00615.09
7.3.70.0060.00614.97
7.3.60.0040.01214.95
7.3.50.0000.01314.93
7.3.40.0060.00315.07
7.3.30.0070.01114.88
7.3.20.0060.01016.59
7.3.10.0050.00816.78
7.3.00.0060.00616.78
7.2.330.0090.00916.80
7.2.320.0110.00816.80
7.2.310.0170.00516.98
7.2.300.0110.00716.92
7.2.290.0030.01516.89
7.2.250.0070.01414.94
7.2.240.0070.01015.18
7.2.230.0070.00714.97
7.2.220.0040.01415.23
7.2.210.0000.01915.39
7.2.200.0100.00715.15
7.2.190.0060.01014.87
7.2.180.0040.01414.93
7.2.170.0130.00014.97
7.2.130.0090.00616.96
7.2.120.0110.00716.97
7.2.110.0090.00317.13
7.2.100.0080.00416.76
7.2.90.0090.00616.84
7.2.80.0040.01016.97
7.2.70.0070.00717.26
7.2.60.0090.00316.91
7.2.50.0050.00517.12
7.2.40.0000.01517.29
7.2.30.0030.00917.18
7.2.20.0060.00617.13
7.2.10.0150.00016.98
7.2.00.0030.00818.18
7.1.330.0000.01615.52
7.1.320.0090.00615.79
7.1.310.0090.00415.79
7.1.300.0030.00915.88
7.1.290.0170.00015.93
7.1.280.0030.01415.89
7.1.270.0070.01115.64
7.1.260.0030.00615.69
7.1.250.0090.00615.75
7.1.100.0080.00418.25
7.1.70.0030.00517.29
7.1.60.0110.01419.40
7.1.50.0200.01034.57
7.1.00.0030.06722.52
7.0.200.0210.00914.72
7.0.140.0030.07322.16
7.0.120.0070.07022.07
7.0.60.0230.06320.00
7.0.50.0100.06018.03
7.0.40.0000.05720.41
7.0.30.0000.06720.14
7.0.20.0030.08720.16
7.0.10.0100.05720.16
7.0.00.0130.03720.26
5.6.280.0000.07721.09
5.6.210.0170.04020.92
5.6.200.0070.04018.20
5.6.190.0130.05320.85
5.6.180.0000.08320.53
5.6.170.0070.06720.75
5.6.160.0000.05320.73
5.6.150.0030.05320.54
5.6.140.0030.06020.48
5.6.130.0000.04320.60
5.6.120.0070.06720.39
5.6.110.0030.07020.54
5.6.100.0130.08020.28
5.6.90.0000.09320.29
5.6.80.0100.07719.69
5.6.70.0030.05019.82
5.6.60.0130.04019.92
5.6.50.0130.06319.65
5.6.40.0300.06319.60
5.6.30.0230.06019.60
5.6.20.0270.06719.96
5.6.10.0170.05019.76
5.6.00.0200.07319.99
5.5.350.0000.04720.63
5.5.340.0100.06318.15
5.5.330.0070.07720.49
5.5.320.0070.08320.33
5.5.310.0070.07320.39
5.5.300.0000.04320.22
5.5.290.0100.07720.06
5.5.280.0070.05020.44
5.5.270.0070.08320.23
5.5.260.0130.06720.33
5.5.250.0000.05319.93
5.5.240.0130.05719.43
5.5.230.0170.07719.44
5.5.220.0100.05019.77
5.5.210.0200.07019.65
5.5.200.0170.07719.70
5.5.190.0200.03719.70
5.5.180.0270.06719.75
5.5.160.0230.08319.63
5.5.150.0270.05019.60
5.5.140.0200.04719.39
5.5.130.0200.05019.68
5.5.120.0330.06019.68
5.5.110.0330.06019.68
5.5.100.0230.05319.46
5.5.90.0270.07019.70
5.5.80.0200.06719.49
5.5.70.0300.07319.59
5.5.60.0230.06719.31
5.5.50.0230.07319.29
5.5.40.0230.06319.45
5.5.30.0300.05719.66
5.5.20.0200.04319.53
5.5.10.0200.07719.49
5.5.00.0300.07019.52
5.4.450.0270.05019.56
5.4.440.0030.08319.72
5.4.430.0000.08319.77
5.4.420.0000.07319.55
5.4.410.0100.07719.48
5.4.400.0070.05018.94
5.4.390.0130.06719.19
5.4.380.0130.04719.22
5.4.370.0200.07019.16
5.4.360.0100.08019.38
5.4.350.0230.07019.22
5.4.340.0230.07018.92
5.4.320.0330.07319.08
5.4.310.0200.07319.07
5.4.300.0230.04019.34
5.4.290.0230.07719.28
5.4.280.0270.07318.95
5.4.270.0530.03018.95
5.4.260.0270.04719.39
5.4.250.0230.07019.15
5.4.240.0170.04018.95
5.4.230.0300.06319.22
5.4.220.0270.07019.38
5.4.210.0230.03719.18
5.4.200.0270.07319.33
5.4.190.0200.06318.91
5.4.180.0200.04718.96
5.4.170.0230.06718.91
5.4.160.0330.06319.14
5.4.150.0400.06319.43
5.4.140.0270.06016.59
5.4.130.0200.04316.66
5.4.120.0300.07016.62
5.4.110.0330.06016.62
5.4.100.0300.06716.56
5.4.90.0170.06716.53
5.4.80.0200.07016.61
5.4.70.0270.06016.59
5.4.60.0330.02716.57
5.4.50.0270.07016.55
5.4.40.0270.07016.57
5.4.30.0270.05316.48
5.4.20.0300.06716.43
5.4.10.0300.04316.48
5.4.00.0200.04315.87
5.3.290.0200.07714.91
5.3.280.0370.06014.76
5.3.270.0330.06714.68
5.3.260.0300.06714.82
5.3.250.0200.05014.75
5.3.240.0230.04014.75
5.3.230.0330.07014.82
5.3.220.0270.07014.73
5.3.210.0230.04314.71
5.3.200.0230.04314.79
5.3.190.0230.06014.69
5.3.180.0170.05014.76
5.3.170.0230.05314.68
5.3.160.0230.05714.71
5.3.150.0200.06314.61
5.3.140.0300.04014.70
5.3.130.0430.04014.77
5.3.120.0230.03714.59
5.3.110.0330.05714.70
5.3.100.0200.03714.20
5.3.90.0270.04314.03
5.3.80.0270.06014.22
5.3.70.0230.07014.25
5.3.60.0330.06014.22
5.3.50.0270.08014.15
5.3.40.0400.04314.05
5.3.30.0200.04314.15
5.3.20.0230.07313.90
5.3.10.0330.04713.70
5.3.00.0270.06013.85
5.2.170.0100.04712.35
5.2.160.0230.05712.35
5.2.150.0330.04712.35
5.2.140.0170.03012.35
5.2.130.0230.03312.35
5.2.120.0200.04012.35
5.2.110.0270.05012.35
5.2.100.0200.03712.35
5.2.90.0170.03312.35
5.2.80.0270.03012.35
5.2.70.0200.03312.35
5.2.60.0300.05312.35
5.2.50.0230.03312.35
5.2.40.0170.05012.35
5.2.30.0100.06712.35
5.2.20.0130.04012.35
5.2.10.0130.05012.35
5.2.00.0170.06012.35
5.1.60.0170.02712.35
5.1.50.0230.05012.35
5.1.40.0200.02712.35
5.1.30.0170.03312.35
5.1.20.0170.05312.35
5.1.10.0170.04712.35
5.1.00.0130.04012.35
5.0.50.0130.04012.35
5.0.40.0100.04012.35
5.0.30.0100.06712.35
5.0.20.0170.03012.35
5.0.10.0100.02012.35
5.0.00.0100.06712.35
4.4.90.0070.03712.35
4.4.80.0100.03012.35
4.4.70.0070.03712.35
4.4.60.0100.02012.35
4.4.50.0100.01712.35
4.4.40.0130.03012.35
4.4.30.0070.04012.35
4.4.20.0070.02012.35
4.4.10.0100.03312.35
4.4.00.0100.05012.35
4.3.110.0070.03712.35
4.3.100.0070.03312.35
4.3.90.0070.02012.35
4.3.80.0100.04012.35
4.3.70.0170.02712.35
4.3.60.0100.03012.35
4.3.50.0070.03712.35
4.3.40.0130.05312.35
4.3.30.0030.04012.35
4.3.20.0070.01712.35
4.3.10.0100.01712.35
4.3.00.0030.01712.35

preferences:
45.71 ms | 401 KiB | 5 Q