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($this->xml->xpath('/note/recursive/val'));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.0140.00018.84
8.3.50.0140.00722.11
8.3.40.0080.00819.05
8.3.30.0070.01119.17
8.3.20.0050.00319.29
8.3.10.0080.00021.33
8.3.00.0080.00022.09
8.2.180.0120.00617.00
8.2.170.0040.01122.96
8.2.160.0090.00920.91
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0140.00026.16
8.2.120.0050.00319.86
8.2.110.0000.01120.82
8.2.100.0120.00018.16
8.2.90.0080.00019.51
8.2.80.0000.00818.18
8.2.70.0030.00617.87
8.2.60.0040.00418.30
8.2.50.0000.00818.07
8.2.40.0040.00418.52
8.2.30.0050.00320.11
8.2.20.0060.00318.07
8.2.10.0050.00218.09
8.2.00.0000.00818.28
8.1.280.0150.00625.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0060.00322.71
8.1.230.0090.00621.45
8.1.220.0050.00318.77
8.1.210.0000.00819.38
8.1.200.0000.00917.85
8.1.190.0000.00817.91
8.1.180.0080.00018.25
8.1.170.0000.00919.06
8.1.160.0050.00219.34
8.1.150.0000.00718.99
8.1.140.0030.00617.86
8.1.130.0030.00318.21
8.1.120.0040.00417.91
8.1.110.0060.00317.84
8.1.100.0000.00817.91
8.1.90.0040.00417.87
8.1.80.0050.00317.80
8.1.70.0000.00717.76
8.1.60.0040.00418.06
8.1.50.0060.00317.76
8.1.40.0060.00317.93
8.1.30.0040.00418.08
8.1.20.0000.00818.06
8.1.10.0030.00617.97
8.1.00.0060.00618.00
8.0.300.0000.00820.45
8.0.290.0040.00417.65
8.0.280.0000.00718.86
8.0.270.0070.00017.71
8.0.260.0030.00317.21
8.0.250.0030.00617.25
8.0.240.0040.00417.47
8.0.230.0000.00717.42
8.0.220.0030.00317.35
8.0.210.0040.00417.25
8.0.200.0030.00317.27
8.0.190.0000.00817.50
8.0.180.0000.00817.37
8.0.170.0000.00717.49
8.0.160.0040.00417.21
8.0.150.0000.00817.20
8.0.140.0070.00317.40
8.0.130.0000.00613.84
8.0.120.0040.00417.30
8.0.110.0070.00317.29
8.0.100.0030.00617.28
8.0.90.0000.00717.30
8.0.80.0120.00317.30
8.0.70.0000.00717.28
8.0.60.0040.00417.51
8.0.50.0040.00417.33
8.0.30.0150.00717.37
8.0.20.0090.01017.54
8.0.10.0000.00717.47
8.0.00.0120.00917.40
7.4.330.0000.00515.08
7.4.320.0030.00316.86
7.4.300.0030.00316.96
7.4.290.0050.00216.97
7.4.280.0060.00616.91
7.4.270.0000.00716.97
7.4.260.0000.00813.79
7.4.250.0000.00816.97
7.4.240.0040.00416.86
7.4.230.0040.00416.73
7.4.220.0100.00717.05
7.4.210.0090.00617.01
7.4.200.0000.00716.69
7.4.190.0040.00417.20
7.4.160.0110.00817.06
7.4.150.0170.00717.40
7.4.140.0120.00917.86
7.4.130.0100.01217.00
7.4.120.0120.00716.96
7.4.110.0180.00016.84
7.4.100.0110.00616.88
7.4.90.0090.00916.97
7.4.80.0050.01319.37
7.4.70.0090.00916.95
7.4.60.0140.00516.65
7.4.50.0030.00616.93
7.4.40.0080.00822.27
7.4.30.0110.00816.76
7.4.10.0050.01215.30
7.4.00.0100.00715.24
7.3.330.0000.00513.82
7.3.320.0030.00313.49
7.3.310.0040.00416.60
7.3.300.0070.00016.79
7.3.290.0090.00616.82
7.3.280.0090.00816.80
7.3.270.0100.00717.40
7.3.260.0130.00418.24
7.3.250.0140.00416.86
7.3.240.0060.01017.03
7.3.230.0100.00717.09
7.3.210.0090.01116.81
7.3.200.0100.01019.39
7.3.190.0100.00716.82
7.3.180.0150.00317.05
7.3.170.0070.01016.86
7.3.160.0030.01316.89
7.3.130.0090.01115.03
7.3.120.0100.00715.16
7.3.110.0070.01015.11
7.3.100.0060.01015.03
7.3.90.0090.00815.13
7.3.80.0040.01115.07
7.3.70.0080.00615.02
7.3.60.0050.00815.12
7.3.50.0060.00715.08
7.3.40.0080.00415.01
7.3.30.0020.01114.93
7.3.20.0020.01216.83
7.3.10.0060.00916.83
7.3.00.0060.00816.86
7.2.330.0160.00316.82
7.2.320.0030.01916.89
7.2.310.0060.01217.04
7.2.300.0030.01317.13
7.2.290.0120.00317.09
7.2.260.0030.01515.34
7.2.250.0090.00915.16
7.2.240.0070.00915.29
7.2.230.0050.01015.26
7.2.220.0070.01015.44
7.2.210.0060.00915.22
7.2.200.0060.00715.17
7.2.190.0050.01015.20
7.2.180.0040.00915.25
7.2.170.0060.00715.15
7.2.160.0030.01015.25
7.2.150.0030.00917.07
7.2.140.0060.00817.00
7.2.130.0110.00517.08
7.2.120.0050.01017.10
7.2.110.0100.00617.08
7.2.100.0090.00616.93
7.2.90.0070.00817.04
7.2.80.0090.00817.14
7.2.70.0080.00917.09
7.2.60.0080.00817.06
7.2.50.0090.00717.02
7.2.40.0100.00817.05
7.2.30.0100.00617.05
7.2.20.0070.00817.09
7.2.10.0060.00916.98
7.2.00.0080.00517.59
7.1.330.0060.00915.94
7.1.320.0090.00515.89
7.1.310.0080.00715.93
7.1.300.0080.00615.93
7.1.290.0070.00615.91
7.1.280.0050.01015.89
7.1.270.0050.00716.03
7.1.260.0020.01115.83
7.1.250.0050.01116.00
7.1.240.0080.00615.90
7.1.230.0070.00515.91
7.1.220.0100.00315.95
7.1.210.0110.00315.97
7.1.200.0040.00615.81
7.1.190.0070.00715.94
7.1.180.0080.00615.96
7.1.170.0070.00715.98
7.1.160.0070.00615.97
7.1.150.0040.00916.11
7.1.140.0050.00716.08
7.1.130.0040.00615.87
7.1.120.0000.01116.00
7.1.110.0070.00915.93
7.1.100.0050.00816.64
7.1.90.0040.01316.01
7.1.80.0070.00815.95
7.1.70.0030.01116.39
7.1.60.0060.00917.07
7.1.50.0060.01216.48
7.1.40.0090.00415.81
7.1.30.0070.00515.82
7.1.20.0040.00615.89
7.1.10.0010.01116.01
7.1.00.0040.03018.13
7.0.330.0060.01015.44
7.0.320.0090.00515.49
7.0.310.0030.01115.58
7.0.300.0080.00815.49
7.0.290.0070.00415.55
7.0.280.0080.00515.48
7.0.270.0020.01315.57
7.0.260.0060.00615.61
7.0.250.0040.00715.70
7.0.240.0020.01315.61
7.0.230.0050.00915.77
7.0.220.0060.00915.58
7.0.210.0070.00715.63
7.0.200.0030.00616.07
7.0.190.0040.00915.59
7.0.180.0070.00815.76
7.0.170.0080.00715.60
7.0.160.0060.00415.58
7.0.150.0100.00515.53
7.0.140.0090.02617.80
7.0.130.0040.00615.69
7.0.120.0040.00915.61
7.0.110.0070.00715.71
7.0.100.0040.01315.62
7.0.90.0050.00515.55
7.0.80.0050.00715.60
7.0.70.0050.00815.59
7.0.60.0030.02217.19
7.0.50.0060.02316.49
7.0.40.0090.03015.82
7.0.30.0100.01815.83
7.0.20.0150.03015.89
7.0.10.0070.01916.00
7.0.00.0070.02015.95
5.6.400.0040.01114.91
5.6.390.0030.00914.80
5.6.380.0080.00614.63
5.6.370.0100.00114.53
5.6.360.0060.00614.42
5.6.350.0050.00514.57
5.6.340.0040.00814.48
5.6.330.0090.00614.54
5.6.320.0080.00914.79
5.6.310.0090.00614.74
5.6.300.0060.00614.64
5.6.290.0050.00814.73
5.6.280.0070.00714.70
5.6.270.0020.00814.83
5.6.260.0080.00814.71
5.6.250.0090.00414.56
5.6.240.0100.00314.82
5.6.230.0080.00614.58
5.6.220.0020.00914.52
5.6.210.0060.02916.62
5.6.200.0080.03215.84
5.6.190.0030.02716.65
5.6.180.0140.01916.64
5.6.170.0110.02116.63
5.6.160.0080.01916.56
5.6.150.0060.03315.74
5.6.140.0070.02415.90
5.6.130.0070.02115.66
5.6.120.0070.02016.86
5.6.110.0080.03016.75
5.6.100.0060.03516.83
5.6.90.0070.03416.81
5.6.80.0060.03216.46
5.6.70.0160.03016.47
5.6.60.0070.00614.63
5.6.50.0030.00814.72
5.6.40.0030.01014.48
5.6.30.0040.00714.46
5.6.20.0060.00514.52
5.6.10.0050.01014.32
5.6.00.0070.00314.45
5.5.380.0070.00614.60
5.5.370.0010.01314.62
5.5.360.0060.00914.66
5.5.350.0170.02616.59
5.5.340.0040.02115.87
5.5.330.0030.02116.43
5.5.320.0100.02516.42
5.5.310.0150.02816.50
5.5.300.0020.02115.68
5.5.290.0040.03315.72
5.5.280.0060.02216.53
5.5.270.0060.03316.57
5.5.260.0120.03016.66
5.5.250.0080.02416.59
5.5.240.0070.02016.45
5.5.230.0080.00714.38
5.5.220.0080.00314.52
5.5.210.0040.00914.52
5.5.200.0100.00514.42
5.5.190.0050.00914.49
5.5.180.0060.00714.30
5.5.170.0060.00914.04
5.5.160.0040.01114.37
5.5.150.0080.00514.33
5.5.140.0060.00814.43
5.5.130.0030.00814.49
5.5.120.0030.00914.51
5.5.110.0060.00614.49
5.5.100.0060.00414.51
5.5.90.0050.00714.26
5.5.80.0020.01114.64
5.5.70.0020.01014.32
5.5.60.0020.01014.33
5.5.50.0020.01214.40
5.5.40.0030.00814.30
5.5.30.0030.00914.41
5.5.20.0060.00514.57
5.5.10.0080.00814.52
5.5.00.0040.00914.47
5.4.450.0030.02014.58
5.4.440.0040.01914.49
5.4.430.0040.01814.58
5.4.420.0050.01514.47
5.4.410.0030.01614.43
5.4.400.0010.01914.37
5.4.390.0030.02514.46
5.4.380.0050.02914.41
5.4.370.0040.02214.44
5.4.360.0060.02814.47
5.4.350.0040.03014.36
5.4.340.0040.03114.37
5.4.330.0030.00811.97
5.4.320.0050.02414.42
5.4.310.0040.02414.37
5.4.300.0050.01614.36
5.4.290.0060.02314.44
5.4.280.0050.02214.42
5.4.270.0040.02014.41
5.4.260.0070.01514.36
5.4.250.0030.02014.36
5.4.240.0040.02414.39
5.4.230.0070.02714.46
5.4.220.0020.03014.47
5.4.210.0060.02814.41
5.4.200.0060.02014.44
5.4.190.0050.02914.45
5.4.180.0030.03114.36
5.4.170.0040.02714.45
5.4.160.0060.02714.38
5.4.150.0150.02014.38
5.4.140.0040.02413.55
5.4.130.0020.02813.52
5.4.120.0030.02813.53
5.4.110.0030.03213.54
5.4.100.0030.02013.55
5.4.90.0020.02113.55
5.4.80.0040.02613.54
5.4.70.0030.03113.49
5.4.60.0040.02513.54
5.4.50.0050.02713.49
5.4.40.0030.02813.48
5.4.30.0040.02813.52
5.4.20.0020.02713.54
5.4.10.0030.01813.53
5.4.00.0020.02813.32
5.3.290.0030.02212.96
5.3.280.0060.01512.90
5.3.270.0060.02812.90
5.3.260.0020.02812.90
5.3.250.0050.02912.93
5.3.240.0040.02712.90
5.3.230.0060.01612.92
5.3.220.0040.01812.91
5.3.210.0040.01812.94
5.3.200.0010.02912.89
5.3.190.0040.01612.90
5.3.180.0050.02712.89
5.3.170.0010.03312.89
5.3.160.0060.03012.91
5.3.150.0020.02912.90
5.3.140.0070.02512.95
5.3.130.0030.02512.88
5.3.120.0050.02212.89
5.3.110.0030.02312.89
5.3.100.0050.02412.71
5.3.90.0050.02512.75
5.3.80.0030.02812.79
5.3.70.0050.02612.75
5.3.60.0050.02512.73
5.3.50.0040.02912.72
5.3.40.0140.02012.68
5.3.30.0030.02512.74
5.3.20.0070.01312.63
5.3.10.0040.02812.58
5.3.00.0060.02612.57
5.2.170.0030.06012.36
5.2.160.0070.05012.36
5.2.150.0000.05012.36
5.2.140.0070.03312.36
5.2.130.0070.05312.36
5.2.120.0030.04712.36
5.2.110.0000.06312.36
5.2.100.0070.04712.36
5.2.90.0030.06312.36
5.2.80.0030.06012.36
5.2.70.0030.03712.36
5.2.60.0070.05312.36
5.2.50.0100.05312.36
5.2.40.0030.03712.36
5.2.30.0030.04012.36
5.2.20.0000.03712.36
5.2.10.0030.06012.36
5.2.00.0030.06312.36
5.1.60.0030.03012.36
5.1.50.0030.05012.36
5.1.40.0070.05312.36
5.1.30.0000.04712.36
5.1.20.0030.06012.36
5.1.10.0000.06012.36
5.1.00.0000.05312.36
5.0.50.0000.05012.36
5.0.40.0030.03012.36
5.0.30.0030.06012.36
5.0.20.0000.03312.36
5.0.10.0070.03312.36
5.0.00.0030.06312.36
4.4.90.0030.03312.36
4.4.80.0000.02712.36
4.4.70.0000.02012.36
4.4.60.0000.02012.36
4.4.50.0100.02712.36
4.4.40.0070.04312.36
4.4.30.0000.03712.36
4.4.20.0000.03012.36
4.4.10.0030.03312.36
4.4.00.0000.04712.36
4.3.110.0000.02012.36
4.3.100.0000.02712.36
4.3.90.0070.03012.36
4.3.80.0030.04312.36
4.3.70.0100.02012.36
4.3.60.0030.02312.36
4.3.50.0030.02312.36
4.3.40.0070.03012.36
4.3.30.0000.02012.36
4.3.20.0000.03712.36
4.3.10.0030.02312.36
4.3.00.0030.03312.36

preferences:
52.35 ms | 401 KiB | 5 Q