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(); $target = $this->xml->xpath('../' . $tag); $target = $target[$offset]; return new self($target->asXML(), false); } if ('val' == $offset) { var_dump(iterator_to_array($this->xml->$offset));die; } 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'];

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.0090.00618.68
8.3.50.0100.00922.11
8.3.40.0140.00419.10
8.3.30.0060.01219.05
8.3.20.0000.00919.16
8.3.10.0030.00521.42
8.3.00.0030.00719.14
8.2.180.0120.00916.75
8.2.170.0120.00322.96
8.2.160.0140.00020.64
8.2.150.0030.01624.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0050.00321.25
8.2.110.0030.00620.63
8.2.100.0060.00618.17
8.2.90.0040.00419.47
8.2.80.0040.00419.50
8.2.70.0050.00317.88
8.2.60.0080.00018.16
8.2.50.0060.00318.07
8.2.40.0040.00418.40
8.2.30.0030.00521.39
8.2.20.0040.00418.08
8.2.10.0040.00418.02
8.2.00.0030.00817.98
8.1.280.0070.01425.92
8.1.270.0030.01223.99
8.1.260.0060.00326.35
8.1.250.0120.00328.09
8.1.240.0030.00622.86
8.1.230.0070.00421.09
8.1.220.0050.00318.77
8.1.210.0030.00519.16
8.1.200.0000.00917.50
8.1.190.0000.00817.91
8.1.180.0080.00018.10
8.1.170.0050.00318.71
8.1.160.0000.00719.22
8.1.150.0060.00318.88
8.1.140.0070.00317.64
8.1.130.0030.00318.05
8.1.120.0020.00517.66
8.1.110.0040.00417.68
8.1.100.0040.00417.61
8.1.90.0030.00517.70
8.1.80.0000.00717.67
8.1.70.0040.00417.67
8.1.60.0040.00417.88
8.1.50.0030.00617.81
8.1.40.0060.00317.82
8.1.30.0000.00817.76
8.1.20.0040.00417.87
8.1.10.0060.00317.74
8.1.00.0040.00417.68
8.0.300.0040.00420.27
8.0.290.0070.00017.43
8.0.280.0030.00318.68
8.0.270.0070.00017.39
8.0.260.0000.00617.04
8.0.250.0030.00617.34
8.0.240.0040.00417.32
8.0.230.0030.00317.18
8.0.220.0070.00017.25
8.0.210.0040.00417.21
8.0.200.0000.00717.27
8.0.190.0060.00317.29
8.0.180.0040.00417.23
8.0.170.0030.00617.30
8.0.160.0070.00017.30
8.0.150.0040.00417.11
8.0.140.0040.00417.09
8.0.130.0060.00013.70
8.0.120.0000.00817.21
8.0.110.0000.00717.05
8.0.100.0040.00417.24
8.0.90.0040.00417.06
8.0.80.0040.01117.29
8.0.70.0000.00717.31
8.0.60.0000.00717.14
8.0.50.0000.00717.24
8.0.30.0100.01017.33
8.0.20.0100.00917.52
8.0.10.0030.00517.40
8.0.00.0110.00917.25
7.4.330.0000.00516.95
7.4.320.0000.00616.84
7.4.300.0080.00016.93
7.4.290.0030.00316.91
7.4.280.0030.00316.73
7.4.270.0070.00016.92
7.4.260.0060.00013.63
7.4.250.0000.00916.90
7.4.240.0000.00716.83
7.4.230.0000.00716.96
7.4.220.0060.01316.62
7.4.210.0100.00616.89
7.4.200.0030.00316.61
7.4.190.0000.00716.88
7.4.160.0100.00716.86
7.4.150.0090.00917.40
7.4.140.0110.00917.86
7.4.130.0110.00916.81
7.4.120.0140.00516.98
7.4.110.0140.00316.88
7.4.100.0100.01316.75
7.4.90.0140.00516.69
7.4.80.0070.01019.39
7.4.70.0080.00816.77
7.4.60.0120.01116.81
7.4.50.0000.00716.84
7.4.40.0070.00322.77
7.4.30.0070.01716.64
7.4.00.0100.00615.23
7.3.330.0040.00313.69
7.3.320.0040.00413.72
7.3.310.0070.00016.70
7.3.300.0000.00616.75
7.3.290.0040.01116.69
7.3.280.0080.00716.70
7.3.270.0000.01817.40
7.3.260.0120.00818.24
7.3.250.0110.00616.70
7.3.240.0160.00016.74
7.3.230.0100.00616.81
7.3.210.0130.00616.71
7.3.200.0160.00619.39
7.3.190.0090.01516.63
7.3.180.0120.00416.71
7.3.170.0060.00916.72
7.3.160.0100.00616.71
7.3.120.0120.00015.01
7.2.330.0170.00016.89
7.2.320.0140.00716.78
7.2.310.0110.00716.75
7.2.300.0120.00917.02
7.2.290.0090.00816.88
7.2.60.0030.01016.71
7.2.00.0000.01119.50
7.1.200.0030.00615.73
7.1.70.0050.00517.34
7.1.60.0080.00317.38
7.1.50.0240.00417.17
7.1.00.0000.07722.51
7.0.200.0080.00816.66
7.0.140.0030.07322.15
7.0.60.0170.07720.16
7.0.50.0030.04317.99
7.0.40.0100.08320.21
7.0.30.0270.04720.29
7.0.20.0270.09020.28
7.0.10.0270.03720.28
7.0.00.0030.04720.33
5.6.280.0000.07721.07
5.6.210.0100.07020.79
5.6.200.0070.07718.32
5.6.190.0100.04320.77
5.6.180.0230.08020.60
5.6.170.0400.06020.62
5.6.160.0170.08020.62
5.6.150.0030.08718.39
5.6.140.0070.08318.41
5.6.130.0030.05718.36
5.6.120.0130.05721.21
5.6.110.0070.04021.06
5.6.100.0130.03321.24
5.6.90.0070.08721.20
5.6.80.0030.08020.59
5.5.350.0270.07720.46
5.5.340.0030.07018.00
5.5.330.0070.08720.38
5.5.320.0130.07320.40
5.5.310.0230.08020.50
5.5.300.0070.06718.11
5.5.290.0100.07318.11
5.5.280.0170.08320.87
5.5.270.0070.07021.02
5.5.260.0100.07721.04
5.5.250.0100.07020.82
5.5.240.0030.07320.26
5.4.450.3370.04719.70
5.4.440.3770.03019.56
5.4.430.4030.03319.55
5.4.420.3600.03719.66
5.4.410.3200.03719.50
5.4.400.3230.03019.27
5.4.390.3470.04019.30
5.4.380.3370.03719.30
5.4.370.3600.04019.39
5.4.360.3570.04019.05
5.4.350.3130.03319.06
5.4.340.3400.04019.34
5.4.320.4070.04319.40
5.4.310.3970.04019.37
5.4.300.3970.04719.28
5.4.290.4030.03319.13
5.4.280.4000.04019.14
5.4.270.3800.03719.29
5.4.260.4100.03019.18
5.4.250.3570.03719.30
5.4.240.3730.03319.08
5.4.230.3000.03719.07
5.4.220.3730.04319.36
5.4.210.3300.04019.36
5.4.200.4130.03319.17
5.4.190.3600.04019.38
5.4.180.4100.03319.08
5.4.170.3370.04019.31
5.4.160.3530.03019.35
5.4.150.3130.03319.05
5.4.140.3130.04016.65
5.4.130.3770.03716.62
5.4.120.3730.03716.80
5.4.110.3330.04316.52
5.4.100.3130.03716.71
5.4.90.3070.04016.70
5.4.80.3630.03716.69
5.4.70.3000.03016.57
5.4.60.3100.02716.66
5.4.50.2770.04316.47
5.4.40.3330.03716.66
5.4.30.3600.03316.66
5.4.20.3070.03716.47
5.4.10.3500.03016.70
5.4.00.3700.03716.28
5.3.290.3730.03314.93
5.3.280.3600.04014.88
5.3.270.3630.01714.79
5.3.260.3330.04014.70
5.3.250.3070.04014.82
5.3.240.3600.03314.79
5.3.230.3830.04014.82
5.3.220.3200.03314.67
5.3.210.2930.04014.59
5.3.200.3070.04314.64
5.3.190.3000.03314.69
5.3.180.2530.03314.74
5.3.170.3230.03314.64
5.3.160.3200.03314.65
5.3.150.3170.03714.84
5.3.140.3130.03714.78
5.3.130.3470.03714.73
5.3.120.3230.06014.63
5.3.110.3100.04014.64
5.3.100.3570.03014.12
5.3.90.3400.03314.11
5.3.80.3170.03314.13
5.3.70.3570.03714.05
5.3.60.3230.03714.11
5.3.50.3670.03014.21
5.3.40.3630.03314.05
5.3.30.3200.03714.17
5.3.20.3600.04013.88
5.3.10.3470.03013.84
5.3.00.3170.04013.64
5.2.170.2700.03711.15
5.2.160.2970.03011.33
5.2.150.2500.03311.34
5.2.140.2800.03311.41
5.2.130.2900.03011.18
5.2.120.2670.03311.17
5.2.110.2600.02711.28
5.2.100.3030.03311.13
5.2.90.2970.02711.36
5.2.80.2870.03011.20
5.2.70.2870.03311.27
5.2.60.2630.02711.33
5.2.50.2800.03311.08
5.2.40.2730.03011.32
5.2.30.2430.03311.03
5.2.20.2930.02711.03
5.2.10.2530.02310.93
5.2.00.2830.03010.79
5.1.60.2530.02010.18
5.1.50.2900.02710.05
5.1.40.2470.02710.25
5.1.30.3030.02010.56
5.1.20.2530.02710.67
5.1.10.2800.03010.17
5.1.00.2770.02310.21
5.0.50.1270.0238.80
5.0.40.1670.0138.43
5.0.30.1330.0308.43
5.0.20.1600.0208.43
5.0.10.1530.0238.43
5.0.00.1270.0308.43
4.4.90.0970.0208.43
4.4.80.1230.0138.43
4.4.70.1630.0178.43
4.4.60.1300.0138.43
4.4.50.1630.0108.43
4.4.40.1600.0308.43
4.4.30.1200.0208.43
4.4.20.1230.0178.43
4.4.10.1230.0178.43
4.4.00.1470.0238.43
4.3.110.1570.0178.43
4.3.100.1270.0138.43
4.3.90.1630.0178.43
4.3.80.1270.0238.43
4.3.70.1430.0138.43
4.3.60.1230.0138.44
4.3.50.1200.0178.45
4.3.40.1500.0238.45
4.3.30.0630.0178.45
4.3.20.0830.0238.45
4.3.10.0830.0278.45
4.3.00.0870.0208.45

preferences:
56.47 ms | 400 KiB | 5 Q