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)) { var_dump($this->xml); return new self($this->xml[$offset]->asXML(), false); } //$this->current = $this->xml->$offset; 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.0140.00517.12
8.3.50.0060.01017.82
8.3.40.0040.01119.13
8.3.30.0120.00319.00
8.3.20.0080.00019.13
8.3.10.0030.00618.95
8.3.00.0100.00719.75
8.2.180.0080.01117.00
8.2.170.0040.01119.33
8.2.160.0060.00922.96
8.2.150.0060.00324.18
8.2.140.0070.01124.66
8.2.130.0150.00326.16
8.2.120.0060.00618.28
8.2.110.0090.00021.37
8.2.100.0030.00920.02
8.2.90.0050.00318.13
8.2.80.0030.00619.03
8.2.70.0060.00317.75
8.2.60.0050.00318.30
8.2.50.0080.00018.18
8.2.40.0040.00419.73
8.2.30.0040.00718.00
8.2.20.0030.00618.05
8.2.10.0040.00418.00
8.2.00.0080.00018.11
8.1.280.0070.00725.92
8.1.270.0050.00323.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0090.00021.15
8.1.230.0080.00418.01
8.1.220.0000.00818.02
8.1.210.0040.00418.77
8.1.200.0060.00617.73
8.1.190.0120.00417.25
8.1.180.0040.00418.10
8.1.170.0050.00317.72
8.1.160.0040.00419.37
8.1.150.0000.00718.89
8.1.140.0000.00917.80
8.1.130.0000.00717.80
8.1.120.0070.00017.75
8.1.110.0000.00717.64
8.1.100.0040.00417.75
8.1.90.0030.00517.78
8.1.80.0070.00017.75
8.1.70.0030.00317.65
8.1.60.0050.00317.74
8.1.50.0040.00417.66
8.1.40.0040.00417.74
8.1.30.0060.00317.92
8.1.20.0110.00017.85
8.1.10.0070.00017.79
8.1.00.0040.00417.75
8.0.300.0000.00718.77
8.0.290.0040.00417.13
8.0.280.0000.00818.81
8.0.270.0000.00717.53
8.0.260.0070.00017.04
8.0.250.0000.00717.19
8.0.240.0080.00017.34
8.0.230.0000.00817.24
8.0.220.0090.00017.25
8.0.210.0070.00017.27
8.0.200.0000.00717.24
8.0.190.0000.00917.21
8.0.180.0030.00917.24
8.0.170.0050.00517.26
8.0.160.0040.00417.32
8.0.150.0000.00817.11
8.0.140.0030.00617.22
8.0.130.0030.00313.68
8.0.120.0030.00617.17
8.0.110.0000.00817.06
8.0.100.0000.00717.23
8.0.90.0000.00917.25
8.0.80.0080.00817.29
8.0.70.0040.00417.13
8.0.60.0000.00817.13
8.0.50.0080.00017.03
8.0.30.0130.00317.30
8.0.20.0060.01417.28
8.0.10.0050.00317.14
8.0.00.0060.01317.00
7.4.330.0060.00013.22
7.4.320.0030.00316.84
7.4.300.0030.00316.75
7.4.290.0000.00716.83
7.4.280.0050.00316.81
7.4.270.0070.00016.86
7.4.260.0000.00813.47
7.4.250.0060.00316.77
7.4.240.0000.00716.80
7.4.230.0000.00816.62
7.4.220.0100.00616.98
7.4.210.0030.01216.83
7.4.200.0000.00716.85
7.4.190.0000.00916.70
7.4.160.0060.00916.94
7.4.150.0070.01716.72
7.4.140.0040.01517.86
7.4.130.0100.01616.78
7.4.120.0060.01216.94
7.4.110.0040.01416.88
7.4.100.0030.01316.71
7.4.90.0030.01516.62
7.4.80.0060.01619.39
7.4.70.0120.00616.71
7.4.60.0070.01417.02
7.4.50.0000.00816.77
7.4.40.0040.01116.85
7.4.30.0070.01016.93
7.4.00.0070.01015.02
7.3.330.0070.00013.59
7.3.320.0030.00313.62
7.3.310.0040.00416.75
7.3.300.0030.00316.58
7.3.290.0080.00916.69
7.3.280.0060.01516.66
7.3.270.0130.00616.71
7.3.260.0170.00816.73
7.3.240.0160.00716.68
7.3.230.0110.00816.70
7.3.210.0070.01016.75
7.3.200.0100.00716.73
7.3.190.0120.01216.61
7.3.180.0160.00016.76
7.3.170.0060.01116.78
7.3.160.0040.01316.66
7.3.120.0060.00915.04
7.2.330.0060.01217.00
7.2.320.0070.01716.85
7.2.310.0130.01016.96
7.2.300.0000.01717.13
7.2.290.0030.01717.13
7.2.60.1070.01415.45
7.2.00.0030.00719.72
7.1.100.0000.01117.92
7.1.70.0040.00417.27
7.1.60.0040.02219.21
7.1.50.0100.00717.22
7.1.00.0030.05722.56
7.0.200.0040.00816.78
7.0.140.0030.07322.23
7.0.120.0030.07322.29
7.0.60.0100.07020.14
7.0.50.0030.04018.04
7.0.40.0030.04320.21
7.0.30.0200.04720.32
7.0.20.0300.04020.42
7.0.10.0100.04720.29
7.0.00.0100.06020.38
5.6.280.0070.07321.26
5.6.210.0030.08720.73
5.6.200.0070.05018.42
5.6.190.0100.04320.56
5.6.180.0200.05020.53
5.6.170.0270.04320.63
5.6.160.0130.08020.64
5.6.150.0070.03718.24
5.6.140.0000.07718.42
5.6.130.0100.04718.25
5.6.120.0070.05721.12
5.6.110.0100.08021.19
5.6.100.0030.06021.14
5.6.90.0100.07021.03
5.6.80.0070.03720.61
5.6.70.0330.07020.43
5.5.350.0230.07720.46
5.5.340.0070.07018.16
5.5.330.0100.03320.59
5.5.320.0030.05320.59
5.5.310.0230.06720.46
5.5.300.0100.08018.07
5.5.290.0030.04318.16
5.5.280.0170.07020.80
5.5.270.0100.05321.00
5.5.260.0070.08321.07
5.5.250.0130.08320.67
5.5.240.0130.07320.36
5.4.450.0100.07719.79
5.4.440.0070.05719.58
5.4.430.0100.06019.57
5.4.420.0130.07719.38
5.4.410.0100.03719.50
5.4.400.0030.06719.14
5.4.390.0000.08318.93
5.4.380.0070.07719.10
5.4.370.0030.08319.29
5.4.360.0170.03019.20
5.4.350.0070.07019.08
5.4.340.0100.07019.30
5.4.320.0100.05018.94
5.4.310.0130.05019.09
5.4.300.0000.05719.39
5.4.290.0170.03718.94
5.4.280.0100.05019.36
5.4.270.0070.04319.17
5.4.260.0070.08019.09
5.4.250.0070.03719.36
5.4.240.0030.04319.37
5.4.230.0030.04719.38
5.4.220.0070.07319.29
5.4.210.0100.05718.93
5.4.200.0070.06018.94
5.4.190.0100.08019.05
5.4.180.0070.04019.05
5.4.170.0030.08319.28
5.4.160.0070.05319.28
5.4.150.0030.05719.46
5.4.140.0030.04316.64
5.4.130.0070.06016.69
5.4.120.0070.04316.55
5.4.110.0030.05316.70
5.4.100.0000.04016.59
5.4.90.0000.07016.57
5.4.80.0130.05716.61
5.4.70.0070.03316.66
5.4.60.0000.04716.71
5.4.50.0070.07016.51
5.4.40.0100.07016.51
5.4.30.0070.04316.78
5.4.20.0030.03716.58
5.4.10.0000.04316.41
5.4.00.0000.04315.94
5.3.290.0000.04714.94
5.3.280.0070.04314.71
5.3.270.0070.04714.82
5.3.260.0030.05314.84
5.3.250.0130.06014.77
5.3.240.0000.06714.74
5.3.230.0030.05014.73
5.3.220.0030.05314.80
5.3.210.0070.08014.79
5.3.200.0130.04014.78
5.3.190.0100.05314.75
5.3.180.0100.08014.83
5.3.170.0070.04014.68
5.3.160.0070.05014.82
5.3.150.0130.05014.79
5.3.140.0030.04314.79
5.3.130.0070.03714.80
5.3.120.0030.04314.71
5.3.110.0030.04314.77
5.3.100.0030.08014.06
5.3.90.0030.08014.16
5.3.80.0030.04314.09
5.3.70.0170.02714.28
5.3.60.0070.03314.18
5.3.50.0130.05714.11
5.3.40.0130.04014.14
5.3.30.0100.07314.00
5.3.20.0070.06713.95
5.3.10.0070.04013.87
5.3.00.0070.07313.82
5.2.170.0100.03011.42
5.2.160.0000.06011.34
5.2.150.0170.05011.38
5.2.140.0070.06011.27
5.2.130.0100.05711.30
5.2.120.0030.05711.27
5.2.110.0070.06011.36
5.2.100.0100.02711.36
5.2.90.0070.06311.24
5.2.80.0000.04311.31
5.2.70.0030.07011.26
5.2.60.0070.06011.17
5.2.50.0070.05011.20
5.2.40.0100.05311.13
5.2.30.0030.06311.14
5.2.20.0070.05711.11
5.2.10.0030.03711.08
5.2.00.0000.06310.89
5.1.60.0030.05310.13
5.1.50.0030.06010.21
5.1.40.0000.05710.16
5.1.30.0030.06310.55
5.1.20.0030.05010.45
5.1.10.0000.03710.00
5.1.00.0030.06010.11
5.0.50.0070.0408.63
5.0.40.0030.0208.50
5.0.30.0070.0278.27
5.0.20.0030.0208.21
5.0.10.0070.0178.21
5.0.00.0000.0338.21
4.4.90.0000.0378.21
4.4.80.0070.0208.21
4.4.70.0070.0308.21
4.4.60.0000.0238.21
4.4.50.0000.0238.21
4.4.40.0030.0578.21
4.4.30.0000.0308.21
4.4.20.0000.0308.21
4.4.10.0000.0278.21
4.4.00.0000.0308.21
4.3.110.0030.0138.21
4.3.100.0030.0238.21
4.3.90.0030.0138.21
4.3.80.0000.0338.21
4.3.70.0000.0338.21
4.3.60.0000.0378.21
4.3.50.0000.0278.21
4.3.40.0000.0378.21
4.3.30.0000.0378.21
4.3.20.0000.0308.21
4.3.10.0000.0378.21
4.3.00.0030.0308.21

preferences:
53.44 ms | 400 KiB | 5 Q