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); var_dump($test = $this->xml->xpath('/note/recursive/val'), (string)$test[1]);die; } 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.0180.00417.13
8.3.50.0100.01222.16
8.3.40.0120.00319.34
8.3.30.0110.00419.51
8.3.20.0100.00020.48
8.3.10.0050.00224.04
8.3.00.0080.00021.03
8.2.180.0120.00316.88
8.2.170.0060.00922.96
8.2.160.0110.00422.76
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00422.74
8.2.110.0040.00722.55
8.2.100.0080.00418.28
8.2.90.0060.00318.41
8.2.80.0000.00918.00
8.2.70.0080.00418.13
8.2.60.0050.00318.30
8.2.50.0030.00518.07
8.2.40.0050.00319.71
8.2.30.0030.00718.45
8.2.20.0000.00918.29
8.2.10.0040.00418.24
8.2.00.0050.00518.17
8.1.280.0090.00925.92
8.1.270.0000.00824.21
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.53
8.1.230.0060.00617.86
8.1.220.0080.00018.29
8.1.210.0030.00619.17
8.1.200.0060.00317.85
8.1.190.0030.00618.03
8.1.180.0030.00618.10
8.1.170.0060.00318.87
8.1.160.0050.00322.35
8.1.150.0040.00419.05
8.1.140.0000.00917.82
8.1.130.0000.00818.21
8.1.120.0040.00417.92
8.1.110.0000.00817.85
8.1.100.0040.00417.82
8.1.90.0040.00417.94
8.1.80.0000.00717.70
8.1.70.0000.00717.82
8.1.60.0080.00017.95
8.1.50.0000.00817.97
8.1.40.0000.00917.91
8.1.30.0030.00518.06
8.1.20.0030.00618.05
8.1.10.0030.00517.85
8.1.00.0040.00417.84
8.0.300.0000.00720.40
8.0.290.0030.00617.54
8.0.280.0040.00418.79
8.0.270.0000.00817.76
8.0.260.0070.00017.28
8.0.250.0030.00317.42
8.0.240.0030.00617.25
8.0.230.0040.00417.41
8.0.220.0000.00817.43
8.0.210.0040.00417.37
8.0.200.0030.00317.46
8.0.190.0040.00417.26
8.0.180.0030.00617.39
8.0.170.0040.00417.36
8.0.160.0040.00417.35
8.0.150.0000.00817.31
8.0.140.0040.00417.30
8.0.130.0000.00613.74
8.0.120.0060.00317.26
8.0.110.0000.00717.45
8.0.100.0000.00817.22
8.0.90.0000.00717.23
8.0.80.0070.01017.36
8.0.70.0070.00017.35
8.0.60.0000.00717.28
8.0.50.0040.00417.38
8.0.30.0130.00617.68
8.0.20.0050.01417.52
8.0.10.0050.00317.50
8.0.00.0120.00817.16
7.4.330.0030.00315.38
7.4.320.0030.00316.99
7.4.300.0040.00416.96
7.4.290.0070.00017.00
7.4.280.0000.00717.00
7.4.270.0070.00017.01
7.4.260.0000.00717.05
7.4.250.0040.00417.01
7.4.240.0040.00316.88
7.4.230.0030.00317.00
7.4.220.0120.00617.11
7.4.210.0050.01217.00
7.4.200.0000.00717.05
7.4.190.0040.00416.75
7.4.160.0070.01516.73
7.4.150.0070.01117.40
7.4.140.0140.00517.86
7.4.130.0070.01117.03
7.4.120.0060.01216.96
7.4.110.0130.01617.02
7.4.100.0120.01216.96
7.4.90.0060.01316.96
7.4.80.0140.00416.77
7.4.70.0080.00817.16
7.4.60.0070.01016.94
7.4.50.0050.00016.84
7.4.40.0020.01222.77
7.4.30.0100.00716.98
7.4.00.0030.00615.23
7.3.330.0030.00313.86
7.3.320.0000.00613.70
7.3.310.0030.00616.87
7.3.300.0070.00016.85
7.3.290.0090.00916.79
7.3.280.0080.00716.78
7.3.270.0110.00717.40
7.3.260.0070.01116.90
7.3.250.0060.01216.89
7.3.240.0110.00716.81
7.3.230.0100.00716.75
7.3.210.0180.00016.83
7.3.200.0170.00719.39
7.3.190.0030.01316.85
7.3.180.0090.01117.07
7.3.170.0140.00717.02
7.3.160.0130.00417.04
7.3.120.0070.00715.18
7.2.330.0090.00917.17
7.2.320.0110.00716.93
7.2.310.0090.00917.20
7.2.300.0090.00916.99
7.2.290.0140.00317.24
7.2.80.0040.00416.66
7.2.60.0030.00916.98
7.1.200.0090.00315.74
7.1.70.0030.01317.48
7.1.60.0090.01619.27
7.1.50.0030.01217.14
7.1.00.0000.08022.66
7.0.200.0070.00316.98
7.0.140.0030.07322.11
7.0.60.0100.06721.85
7.0.50.0200.07018.16
7.0.40.0130.04720.26
7.0.30.0500.07320.38
7.0.20.0370.07320.34
7.0.10.0070.05720.41
7.0.00.0030.04720.46
5.6.280.0130.06321.18
5.6.210.0030.04321.03
5.6.200.0030.04018.40
5.6.190.0130.08320.93
5.6.180.0300.08320.57
5.6.170.0300.07720.74
5.6.160.0070.08320.73
5.6.150.0070.04318.30
5.6.140.0070.05318.48
5.6.130.0030.07718.40
5.6.120.0070.03721.32
5.6.110.0070.08321.21
5.6.100.0070.06721.18
5.6.90.0130.07021.16
5.6.80.0170.07320.68
5.5.350.0230.05720.67
5.5.340.0100.06718.20
5.5.330.0100.08020.50
5.5.320.0270.08720.45
5.5.310.0230.08320.49
5.5.300.0030.08318.20
5.5.290.0130.07018.17
5.5.280.0100.08721.12
5.5.270.0070.09021.11
5.5.260.0130.08020.96
5.5.250.0130.06320.82
5.5.240.0400.06720.35
5.4.450.0000.04019.63
5.4.440.0000.04319.61
5.4.430.0000.03719.47
5.4.420.0030.03719.59
5.4.410.0000.04019.33
5.4.400.0000.04319.46
5.4.390.0030.05719.44
5.4.380.0000.03719.16
5.4.370.0000.04319.28
5.4.360.0070.06319.47
5.4.350.0030.07319.15
5.4.340.0030.07719.27
5.4.320.0000.04319.13
5.4.310.0030.07319.27
5.4.300.0000.08019.26
5.4.290.0130.06319.13
5.4.280.0070.07319.46
5.4.270.0000.06719.45
5.4.260.0030.07319.18
5.4.250.0030.06019.37
5.4.240.0170.06319.32
5.4.230.0100.05719.36
5.4.220.0030.05319.40
5.4.210.0000.08019.45
5.4.200.0070.07719.14
5.4.190.0000.07719.12
5.4.180.0030.05019.46
5.4.170.0100.04019.45
5.4.160.0100.07019.11
5.4.150.0030.06719.11
5.4.140.0030.04316.55
5.4.130.0030.07016.61
5.4.120.0030.07016.63
5.4.110.0070.07016.54
5.4.100.0070.07016.78
5.4.90.0030.07016.78
5.4.80.0070.06716.75
5.4.70.0070.05016.65
5.4.60.0030.06716.75
5.4.50.0030.04316.71
5.4.40.0070.06016.59
5.4.30.0000.05316.73
5.4.20.0000.06716.73
5.4.10.0070.06716.69
5.4.00.0070.07016.02
5.3.290.0000.08314.90
5.3.280.0070.06314.91
5.3.270.0030.03714.76
5.3.260.0070.04014.86
5.3.250.0100.04014.95
5.3.240.0100.06714.79
5.3.230.0070.07014.75
5.3.220.0030.07014.82
5.3.210.0030.07014.76
5.3.200.0000.07014.91
5.3.190.0030.07314.86
5.3.180.0070.05314.81
5.3.170.0200.05014.88
5.3.160.0100.04014.79
5.3.150.0000.05014.71
5.3.140.0030.07714.86
5.3.130.0070.07014.69
5.3.120.0100.06314.85
5.3.110.0100.06314.89
5.3.100.0030.07714.18
5.3.90.0000.04714.22
5.3.80.0030.04714.38
5.3.70.0030.03314.28
5.3.60.0030.07014.16
5.3.50.0100.07014.10
5.3.40.0070.06314.20
5.3.30.0000.04714.06
5.3.20.0030.04014.09
5.3.10.0100.06313.82
5.3.00.0030.06313.97
5.2.170.0000.06711.87
5.2.160.0070.05311.87
5.2.150.0000.04311.87
5.2.140.0000.03311.87
5.2.130.0030.06011.87
5.2.120.0100.05311.87
5.2.110.0000.06011.87
5.2.100.0000.06311.87
5.2.90.0030.05711.87
5.2.80.0030.05311.87
5.2.70.0000.04011.87
5.2.60.0000.03711.87
5.2.50.0000.05711.87
5.2.40.0000.05311.87
5.2.30.0030.04711.87
5.2.20.0000.04711.87
5.2.10.0000.06311.87
5.2.00.0030.06011.87
5.1.60.0030.05311.87
5.1.50.0070.05011.87
5.1.40.0070.02711.87
5.1.30.0000.03711.87
5.1.20.0070.05311.87
5.1.10.0000.05711.87
5.1.00.0070.05311.87
5.0.50.0030.04711.87
5.0.40.0000.03711.87
5.0.30.0030.06311.87
5.0.20.0030.03711.87
5.0.10.0030.05311.87
5.0.00.0000.05011.87
4.4.90.0000.02011.87
4.4.80.0000.03311.87
4.4.70.0030.02311.87
4.4.60.0030.02311.87
4.4.50.0000.03711.87
4.4.40.0000.02711.87
4.4.30.0000.03311.87
4.4.20.0000.02011.87
4.4.10.0000.03311.87
4.4.00.0070.05011.87
4.3.110.0000.02311.87
4.3.100.0000.03311.87
4.3.90.0030.02011.87
4.3.80.0000.04311.87
4.3.70.0000.03711.87
4.3.60.0030.01711.87
4.3.50.0000.02011.87
4.3.40.0000.04311.87
4.3.30.0030.02011.87
4.3.20.0000.04011.87
4.3.10.0000.03711.87
4.3.00.0000.03311.87

preferences:
35.43 ms | 401 KiB | 5 Q