3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $filePath; private $isUrl; 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 ($this->xml->$offset->count() > 1) { return new self($this->xml->$offset->asXML(), false); } return $this->xml->$offset; } 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((string)$xml['note']['recursive']);

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.0120.00318.43
8.3.50.0120.01017.79
8.3.40.0120.01218.79
8.3.30.0070.00719.10
8.3.20.0050.00318.98
8.3.10.0060.00319.10
8.3.00.0080.00019.63
8.2.180.0070.00717.00
8.2.170.0110.00422.96
8.2.160.0060.01019.03
8.2.150.0030.00724.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00221.24
8.2.110.0030.00621.09
8.2.100.0030.00918.03
8.2.90.0070.00219.50
8.2.80.0040.00419.53
8.2.70.0040.00417.75
8.2.60.0080.00018.17
8.2.50.0040.00418.07
8.2.40.0060.00318.34
8.2.30.0050.00518.18
8.2.20.0050.00517.99
8.2.10.0000.00817.96
8.2.00.0000.00919.62
8.1.280.0180.00025.92
8.1.270.0050.00323.99
8.1.260.0080.00026.35
8.1.250.0070.00728.09
8.1.240.0030.00624.08
8.1.230.0040.00721.11
8.1.220.0000.00817.89
8.1.210.0040.00418.81
8.1.200.0000.01017.61
8.1.190.0030.00517.79
8.1.180.0000.00818.10
8.1.170.0050.00319.04
8.1.160.0040.00419.08
8.1.150.0040.00418.91
8.1.140.0030.00617.74
8.1.130.0000.00717.73
8.1.120.0040.00417.63
8.1.110.0040.00417.55
8.1.100.0040.00417.68
8.1.90.0040.00417.66
8.1.80.0080.00017.60
8.1.70.0030.00317.61
8.1.60.0080.00017.66
8.1.50.0000.00917.56
8.1.40.0000.00917.65
8.1.30.0030.00617.84
8.1.20.0030.00517.83
8.1.10.0000.00717.73
8.1.00.0000.00817.71
8.0.300.0060.00320.23
8.0.290.0020.00516.88
8.0.280.0000.00718.64
8.0.270.0040.00417.04
8.0.260.0030.00517.04
8.0.250.0000.00717.16
8.0.240.0000.01017.16
8.0.230.0070.00017.25
8.0.220.0000.00717.07
8.0.210.0000.00817.10
8.0.200.0070.00017.06
8.0.190.0040.00417.16
8.0.180.0000.00817.18
8.0.170.0080.00017.11
8.0.160.0000.00717.09
8.0.150.0050.00317.07
8.0.140.0030.00617.11
8.0.130.0040.00513.51
8.0.120.0030.00616.96
8.0.110.0050.00317.09
8.0.100.0040.00416.98
8.0.90.0000.00717.00
8.0.80.0120.00917.07
8.0.70.0040.00417.13
8.0.60.0030.00617.09
8.0.50.0080.00017.08
8.0.30.0120.00917.19
8.0.20.0090.01017.17
8.0.10.0040.00417.28
8.0.00.0070.01016.88
7.4.330.0000.00513.18
7.4.320.0060.00016.71
7.4.300.0060.00016.83
7.4.290.0000.00716.86
7.4.280.0000.00716.79
7.4.270.0000.00816.86
7.4.260.0030.00313.48
7.4.250.0000.00816.75
7.4.240.0020.00516.76
7.4.230.0040.00416.45
7.4.220.0070.01116.66
7.4.210.0140.00616.68
7.4.200.0040.00416.76
7.4.190.0040.00416.95
7.4.160.0060.00916.80
7.4.150.0070.01116.67
7.4.140.0140.01417.86
7.4.130.0070.01416.59
7.4.120.0090.01216.77
7.4.110.0150.00716.73
7.4.100.0120.00616.85
7.4.90.0150.00616.52
7.4.80.0040.01419.39
7.4.70.0100.01416.73
7.4.60.0060.01016.57
7.4.50.0000.00616.79
7.4.40.0060.01016.39
7.4.30.0060.01016.66
7.4.00.0030.01014.79
7.3.330.0040.00413.36
7.3.320.0000.00513.53
7.3.310.0040.00416.57
7.3.300.0000.00716.47
7.3.290.0070.01116.54
7.3.280.0060.01316.54
7.3.270.0060.01016.61
7.3.260.0100.00816.62
7.3.240.0100.00616.52
7.3.230.0090.00916.50
7.3.210.0060.01516.59
7.3.200.0070.01016.84
7.3.190.0060.01316.87
7.3.180.0070.01016.73
7.3.170.0080.00816.69
7.3.160.0060.00916.54
7.3.120.0110.00715.18
7.2.330.0150.00316.81
7.2.320.0140.00816.95
7.2.310.0040.01416.97
7.2.300.0120.00916.99
7.2.290.0090.01216.90
7.2.00.0030.01019.58
7.1.100.0000.00918.21
7.1.70.0060.00317.00
7.1.60.0060.01919.25
7.1.50.0260.01335.09
7.1.00.0100.06722.59
7.0.200.0240.00716.68
7.0.140.0000.07722.20
7.0.120.0030.07022.21
7.0.60.0200.08021.91
7.0.50.0070.07318.01
7.0.40.0130.07320.16
7.0.30.0230.04020.41
7.0.20.0170.04020.23
7.0.10.0100.04720.27
7.0.00.0070.08720.32
5.6.210.0000.08720.68
5.6.200.0100.07018.41
5.6.190.0070.08020.77
5.6.180.0270.06720.70
5.6.170.0270.05320.66
5.6.160.0170.06720.62
5.6.150.0100.05018.19
5.6.140.0170.06018.33
5.6.130.0070.05318.27
5.6.120.0100.08021.19
5.6.110.0100.06321.02
5.6.100.0200.07021.17
5.6.90.0030.09021.22
5.6.80.0170.07020.57
5.5.350.0230.06720.58
5.5.340.0030.05018.21
5.5.330.0030.09020.38
5.5.320.0370.06720.42
5.5.310.0400.06720.32
5.5.300.0030.04018.08
5.5.290.0170.07318.11
5.5.280.0130.08321.03
5.5.270.0030.05721.09
5.5.260.0130.07720.80
5.5.250.0070.08720.74
5.5.240.0100.08020.41
5.4.450.3270.04319.60
5.4.440.3400.03719.43
5.4.430.3300.03719.50
5.4.420.3870.04319.59
5.4.410.3700.03719.45
5.4.400.3630.03719.00
5.4.390.3630.04319.38
5.4.380.3930.03019.17
5.4.370.3570.04019.00
5.4.360.3000.03319.42
5.4.350.3870.03719.37
5.4.340.4200.03719.27
5.4.320.4030.03719.04
5.4.310.3830.04019.11
5.4.300.3830.03719.44
5.4.290.3200.04319.26
5.4.280.3670.03719.41
5.4.270.3500.03319.00
5.4.260.3530.04019.41
5.4.250.3370.03719.25
5.4.240.3470.04019.09
5.4.230.3530.04019.26
5.4.220.4100.04019.10
5.4.210.3400.03319.28
5.4.200.3830.04719.17
5.4.190.3300.04019.16
5.4.180.3600.04019.09
5.4.170.3670.03719.09
5.4.160.4270.03718.99
5.4.150.4270.04019.18
5.4.140.3430.03716.59
5.4.130.3930.03316.52
5.4.120.3670.03316.60
5.4.110.3970.04716.54
5.4.100.3670.03716.57
5.4.90.3370.03316.61
5.4.80.3430.03716.55
5.4.70.3400.03016.68
5.4.60.3870.03716.63
5.4.50.3870.03316.65
5.4.40.3830.04016.58
5.4.30.4370.03316.57
5.4.20.3530.04016.51
5.4.10.3630.04016.64
5.4.00.3600.03316.03
5.3.290.4470.05014.77
5.3.280.3870.03714.74
5.3.270.3330.04314.75
5.3.260.4030.04314.77
5.3.250.4500.03314.72
5.3.240.4230.03714.70
5.3.230.3600.04314.72
5.3.220.4200.04014.67
5.3.210.4200.04014.73
5.3.200.3400.04014.72
5.3.190.3370.04014.71
5.3.180.3670.03714.81
5.3.170.3530.04014.70
5.3.160.3870.04014.73
5.3.150.3600.03314.70
5.3.140.4400.04314.77
5.3.130.4430.04314.77
5.3.120.3930.04314.79
5.3.110.3970.03314.69
5.3.100.3670.03714.18
5.3.90.3600.03714.23
5.3.80.3270.04014.08
5.3.70.3870.03314.18
5.3.60.4300.03314.15
5.3.50.4300.03714.06
5.3.40.3370.04014.17
5.3.30.3330.03714.15
5.3.20.3330.03713.84
5.3.10.3430.03313.77
5.3.00.3370.03313.68
5.2.170.3730.02311.37
5.2.160.3400.03311.27
5.2.150.2800.03011.36
5.2.140.2800.02711.30
5.2.130.2900.02011.23
5.2.120.2870.03011.36
5.2.110.2770.02711.14
5.2.100.2800.02711.32
5.2.90.2870.02711.21
5.2.80.2730.03011.20
5.2.70.2800.02311.11
5.2.60.2730.03011.16
5.2.50.2770.03011.23
5.2.40.2130.03011.14
5.2.30.2200.03011.18
5.2.20.2400.02711.00
5.2.10.2470.03310.98
5.2.00.2570.03710.93
5.1.60.2830.02710.10
5.1.50.2530.02710.24
5.1.40.2530.02010.08
5.1.30.2100.02710.37
5.1.20.2200.02710.55
5.1.10.2530.02710.05
5.1.00.2600.02310.05
5.0.50.1500.0278.59
5.0.40.1500.0208.49
5.0.30.1430.0338.31
5.0.20.1500.0208.28
5.0.10.1430.0238.24
5.0.00.1570.0338.19
4.4.90.1070.0136.33
4.4.80.1100.0176.33
4.4.70.1330.0206.33
4.4.60.1270.0176.33
4.4.50.1470.0176.33
4.4.40.1130.0236.33
4.4.30.1300.0136.33
4.4.20.1100.0176.33
4.4.10.1570.0106.33
4.4.00.1600.0276.33
4.3.110.1400.0206.33
4.3.100.1270.0176.33
4.3.90.1070.0176.33
4.3.80.1530.0236.33
4.3.70.1530.0176.33
4.3.60.1470.0176.33
4.3.50.1770.0106.33
4.3.40.1400.0276.33
4.3.30.0800.0176.33
4.3.20.0870.0136.33
4.3.10.0900.0206.33
4.3.00.0900.0206.33

preferences:
40.35 ms | 401 KiB | 5 Q