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(); /*$parent = $this->xml->xpath('../'); $parent = $parent[0];*/ $target = $parent->xpath('../' . $tag . '[' . $offset . ']'); var_dump($target); $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']; var_dump($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.0150.00018.80
8.3.50.0140.00622.16
8.3.40.0100.00719.21
8.3.30.0180.00019.18
8.3.20.0110.00720.54
8.3.10.0040.00422.33
8.3.00.0110.00422.59
8.2.180.0100.01019.04
8.2.170.0210.00022.96
8.2.160.0080.00821.32
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0070.00726.16
8.2.120.0040.00417.88
8.2.110.0080.00022.71
8.2.100.0110.00018.05
8.2.90.0030.00519.44
8.2.80.0060.00318.18
8.2.70.0050.00318.00
8.2.60.0040.00418.18
8.2.50.0080.00018.07
8.2.40.0000.00818.41
8.2.30.0060.00318.41
8.2.20.0080.00018.13
8.2.10.0000.00819.77
8.2.00.0080.00318.14
8.1.280.0140.00725.92
8.1.270.0060.00322.44
8.1.260.0120.00326.35
8.1.250.0070.00728.09
8.1.240.0070.00324.08
8.1.230.0090.00319.35
8.1.220.0080.00018.14
8.1.210.0050.00318.77
8.1.200.0060.00317.50
8.1.190.0050.00318.03
8.1.180.0080.00018.10
8.1.170.0000.00818.89
8.1.160.0040.00422.23
8.1.150.0040.00419.00
8.1.140.0040.00417.67
8.1.130.0040.00418.14
8.1.120.0050.00317.68
8.1.110.0040.00417.82
8.1.100.0000.00817.80
8.1.90.0040.00417.75
8.1.80.0000.00817.84
8.1.70.0040.00417.72
8.1.60.0080.00017.86
8.1.50.0000.00917.79
8.1.40.0030.00517.84
8.1.30.0000.00917.94
8.1.20.0000.00817.94
8.1.10.0000.00817.91
8.1.00.0040.00417.75
8.0.300.0070.00018.77
8.0.290.0060.00317.43
8.0.280.0000.00718.75
8.0.270.0030.00317.57
8.0.260.0030.00517.19
8.0.250.0030.00317.26
8.0.240.0040.00417.33
8.0.230.0000.00717.30
8.0.220.0030.00317.30
8.0.210.0050.00317.21
8.0.200.0060.00017.29
8.0.190.0070.00017.19
8.0.180.0040.00417.30
8.0.170.0050.00417.19
8.0.160.0040.00417.20
8.0.150.0040.00417.15
8.0.140.0000.00717.13
8.0.130.0000.00613.71
8.0.120.0050.00317.15
8.0.110.0040.00417.27
8.0.100.0040.00417.27
8.0.90.0040.00417.11
8.0.80.0060.01217.26
8.0.70.0000.00817.32
8.0.60.0040.00417.31
8.0.50.0020.00517.29
8.0.30.0070.01217.24
8.0.20.0130.00917.54
8.0.10.0040.00417.23
8.0.00.0090.01017.09
7.4.330.0050.00015.29
7.4.320.0030.00316.83
7.4.300.0000.00616.95
7.4.290.0070.00016.82
7.4.280.0030.00316.65
7.4.270.0040.00416.82
7.4.260.0000.00716.71
7.4.250.0000.00716.81
7.4.240.0040.00416.87
7.4.230.0030.00316.72
7.4.220.0100.00716.93
7.4.210.0050.01116.93
7.4.200.0070.00016.71
7.4.190.0050.00217.04
7.4.160.0090.00616.73
7.4.150.0070.01117.40
7.4.140.0170.00217.86
7.4.130.0110.01016.84
7.4.120.0130.00316.93
7.4.110.0110.00716.82
7.4.100.0170.00316.86
7.4.90.0110.00716.83
7.4.80.0100.00717.01
7.4.70.0090.00916.85
7.4.60.0130.00316.58
7.4.50.0060.00316.76
7.4.40.0130.00322.77
7.4.30.0100.00716.87
7.4.00.0060.00815.23
7.3.330.0000.00613.71
7.3.320.0000.00613.72
7.3.310.0070.00016.68
7.3.300.0070.00016.61
7.3.290.0060.00916.70
7.3.280.0110.00916.74
7.3.270.0090.00917.40
7.3.260.0110.00716.77
7.3.250.0150.00816.87
7.3.240.0110.00616.91
7.3.230.0080.00816.74
7.3.210.0060.01216.63
7.3.200.0140.00619.39
7.3.190.0100.01016.71
7.3.180.0070.01016.66
7.3.170.0090.00916.88
7.3.160.0060.01016.68
7.3.120.0190.00314.85
7.3.110.0150.01014.79
7.3.100.0250.00415.19
7.3.90.0200.00714.74
7.3.80.0160.01314.73
7.3.70.0100.01515.00
7.3.60.0210.00815.06
7.3.50.0200.00515.18
7.3.40.0110.01815.07
7.3.30.0120.01214.91
7.3.20.0070.01016.90
7.3.10.0070.00716.89
7.3.00.0110.00416.90
7.2.330.0130.01017.04
7.2.320.0070.01016.85
7.2.310.0030.01316.95
7.2.300.0080.00816.69
7.2.290.0070.01016.80
7.2.240.0110.02015.21
7.2.230.0200.00915.09
7.2.220.0190.01215.20
7.2.210.0190.00715.13
7.2.200.0180.01215.16
7.2.190.0170.01315.19
7.2.180.0160.01315.22
7.2.170.0160.00915.12
7.2.160.0150.01015.27
7.2.150.0090.00617.18
7.2.140.0040.01117.00
7.2.130.0030.01217.09
7.2.120.0090.00616.98
7.2.110.0100.00717.03
7.2.100.0030.01317.02
7.2.90.0070.00717.21
7.2.80.0000.01817.11
7.2.70.0100.00317.08
7.2.60.0020.01017.10
7.2.50.0000.01017.02
7.2.40.0070.00717.01
7.2.30.0040.00816.96
7.2.20.0090.00616.95
7.2.10.0070.01117.11
7.2.00.0050.00718.38
7.1.330.0100.02016.00
7.1.320.0110.01515.69
7.1.310.0190.00915.93
7.1.300.0130.01415.89
7.1.290.0110.00915.95
7.1.280.0110.01415.95
7.1.270.0090.00615.68
7.1.260.0050.00315.89
7.1.250.0030.01415.90
7.1.200.0030.01015.85
7.1.100.0030.01018.31
7.1.70.0000.01217.37
7.1.60.0120.01219.82
7.1.50.0100.01017.08
7.1.00.0130.06722.45
7.0.200.0100.00716.84
7.0.140.0030.06722.15
7.0.60.0100.08020.14
7.0.50.0000.08718.06
7.0.40.0070.08720.20
7.0.30.0470.04020.23
7.0.20.0300.07020.29
7.0.10.0000.07720.28
7.0.00.0070.05020.20
5.6.280.0100.06721.22
5.6.210.0000.09020.79
5.6.200.0100.08018.40
5.6.190.0200.07720.56
5.6.180.0270.04020.61
5.6.170.0200.03720.69
5.6.160.0100.03720.80
5.6.150.0030.04318.32
5.6.140.0030.05318.20
5.6.130.0100.08718.24
5.6.120.0030.04021.22
5.6.110.0030.08721.23
5.6.100.0030.05321.03
5.6.90.0230.05721.19
5.6.80.0170.06020.46
5.6.70.4100.04320.44
5.5.350.0000.03720.57
5.5.340.0070.08318.21
5.5.330.0070.08320.59
5.5.320.0270.06320.44
5.5.310.0300.07020.39
5.5.300.0070.04718.03
5.5.290.0130.07718.04
5.5.280.0070.05021.12
5.5.270.0100.08320.76
5.5.260.0100.07720.87
5.5.250.0130.03020.74
5.5.240.0000.08320.29
5.4.450.0270.06319.55
5.4.440.0370.06719.48
5.4.430.0370.06719.66
5.4.420.0200.08319.63
5.4.410.0300.06319.28
5.4.400.0270.06319.07
5.4.390.0270.04719.14
5.4.380.0270.05719.07
5.4.370.0230.06319.41
5.4.360.0270.04019.35
5.4.350.0470.03019.26
5.4.340.0270.07019.18
5.4.320.0230.05319.40
5.4.310.0270.07719.07
5.4.300.0200.05319.09
5.4.290.0230.04319.39
5.4.280.0330.03719.08
5.4.270.0270.03719.14
5.4.260.0270.04719.09
5.4.250.0270.04019.23
5.4.240.0330.04319.14
5.4.230.0200.08319.14
5.4.220.0230.05319.21
5.4.210.0270.06719.15
5.4.200.0330.04319.39
5.4.190.0230.08019.23
5.4.180.0300.04719.05
5.4.170.0130.05319.23
5.4.160.0430.03319.31
5.4.150.0370.06319.14
5.4.140.0530.05016.48
5.4.130.0330.05716.61
5.4.120.0200.06016.64
5.4.110.0200.05316.53
5.4.100.0430.05016.71
5.4.90.0330.04316.70
5.4.80.0270.06716.71
5.4.70.0270.06016.53
5.4.60.0270.04316.50
5.4.50.0300.02716.45
5.4.40.0230.07016.65
5.4.30.0270.07016.34
5.4.20.0230.07016.68
5.4.10.0370.06716.67
5.4.00.0200.07316.15
5.3.290.0300.07014.95
5.3.280.0300.05314.82
5.3.270.0170.05014.82
5.3.260.0270.07714.68
5.3.250.0270.06014.84
5.3.240.0200.05314.68
5.3.230.0270.05714.71
5.3.220.0230.03714.65
5.3.210.0300.06014.75
5.3.200.0170.06014.64
5.3.190.0230.04014.67
5.3.180.0270.05314.76
5.3.170.0270.06314.75
5.3.160.0270.03314.64
5.3.150.0300.04714.64
5.3.140.0230.03714.63
5.3.130.0270.04314.74
5.3.120.0270.07314.63
5.3.110.0300.06314.65
5.3.100.0270.06714.13
5.3.90.0270.06314.10
5.3.80.0330.06014.29
5.3.70.0400.04314.20
5.3.60.0230.04014.08
5.3.50.0300.06714.03
5.3.40.0270.04714.05
5.3.30.0270.07314.20
5.3.20.0200.04713.93
5.3.10.0330.05713.74
5.3.00.0330.06013.71
5.2.170.0230.05311.54
5.2.160.0200.06311.54
5.2.150.0170.04011.57
5.2.140.0270.05711.57
5.2.130.0200.06011.59
5.2.120.0230.04011.59
5.2.110.0170.04311.59
5.2.100.0300.04311.61
5.2.90.0300.04711.61
5.2.80.0230.02711.61
5.2.70.0270.02311.62
5.2.60.0230.06311.64
5.2.50.0270.06311.64
5.2.40.0200.03011.64
5.2.30.0170.05011.64
5.2.20.0200.06011.64
5.2.10.0270.05011.64
5.2.00.0270.05311.64
5.1.60.0170.03711.64
5.1.50.0230.05011.65
5.1.40.0230.03011.67
5.1.30.0170.02711.67
5.1.20.0330.03711.67
5.1.10.0170.05711.68
5.1.00.0130.04311.68
5.0.50.0100.03011.69
5.0.40.0130.02711.71
5.0.30.0200.04711.72
5.0.20.0100.03311.73
5.0.10.0130.02311.74
5.0.00.0130.06311.75
4.4.90.0170.02711.64
4.4.80.0100.03711.64
4.4.70.0070.03711.64
4.4.60.0070.03311.64
4.4.50.0070.02011.64
4.4.40.0070.05311.64
4.4.30.0100.03711.66
4.4.20.0100.03311.67
4.4.10.0130.03311.69
4.4.00.0070.04311.71
4.3.110.0030.02711.72
4.3.100.0130.03311.73
4.3.90.0100.02011.73
4.3.80.0070.05011.75
4.3.70.0070.02711.75
4.3.60.0130.01311.75
4.3.50.0130.03011.75
4.3.40.0130.04711.75
4.3.30.0030.03711.75
4.3.20.0070.03311.75
4.3.10.0070.03711.75
4.3.00.0070.03011.75

preferences:
36.37 ms | 401 KiB | 5 Q