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) { var_dump(preg_match('/(\w+)(\[\d+\])/', $offset)); if ($this->xml->getName() == $offset) { return $this; } if (preg_match('/(<node>\w+)(<key>\[\d+\])/', $offset, $nodes)) { var_dump($nodes); return new self($this->xml[$offset]->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']; $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.0190.00319.00
8.3.50.0120.01122.35
8.3.40.0060.01519.52
8.3.30.0110.00419.29
8.3.20.0040.00420.50
8.3.10.0120.00323.86
8.3.00.0060.00322.75
8.2.180.0140.00317.25
8.2.170.0120.00322.96
8.2.160.0140.00322.26
8.2.150.0040.01124.18
8.2.140.0100.00624.66
8.2.130.0070.00726.16
8.2.120.0100.00320.11
8.2.110.0060.00322.45
8.2.100.0060.00618.28
8.2.90.0000.00819.47
8.2.80.0040.00418.28
8.2.70.0090.00018.13
8.2.60.0030.00618.18
8.2.50.0060.00318.07
8.2.40.0040.00418.28
8.2.30.0030.00618.36
8.2.20.0030.00618.27
8.2.10.0050.00318.25
8.2.00.0040.00418.23
8.1.280.0110.01125.92
8.1.270.0090.00323.99
8.1.260.0030.00526.35
8.1.250.0070.01028.09
8.1.240.0030.00624.13
8.1.230.0090.00319.54
8.1.220.0040.00417.91
8.1.210.0000.00818.77
8.1.200.0060.00617.72
8.1.190.0080.00017.90
8.1.180.0080.00018.10
8.1.170.0000.00818.77
8.1.160.0000.00822.34
8.1.150.0040.00419.05
8.1.140.0040.00417.77
8.1.130.0030.00618.01
8.1.120.0040.00417.97
8.1.110.0040.00417.79
8.1.100.0000.00817.84
8.1.90.0040.00417.95
8.1.80.0000.00717.88
8.1.70.0030.00317.80
8.1.60.0000.00917.91
8.1.50.0030.00618.01
8.1.40.0050.00217.96
8.1.30.0000.00818.13
8.1.20.0060.00317.99
8.1.10.0000.00817.95
8.1.00.0030.00517.98
8.0.300.0040.00418.77
8.0.290.0040.00417.53
8.0.280.0030.00318.73
8.0.270.0030.00517.44
8.0.260.0000.00817.22
8.0.250.0030.00417.52
8.0.240.0070.00017.47
8.0.230.0070.00017.51
8.0.220.0070.00017.31
8.0.210.0070.00017.31
8.0.200.0030.00317.37
8.0.190.0030.00617.32
8.0.180.0000.00717.48
8.0.170.0060.00317.29
8.0.160.0040.00417.44
8.0.150.0070.00017.32
8.0.140.0050.00317.23
8.0.130.0000.00813.78
8.0.120.0060.00317.39
8.0.110.0040.00417.25
8.0.100.0080.00017.24
8.0.90.0080.00017.43
8.0.80.0090.01217.39
8.0.70.0030.00617.29
8.0.60.0040.00417.42
8.0.50.0000.00817.41
8.0.30.0120.00817.82
8.0.20.0140.00617.55
8.0.10.0040.00417.52
8.0.00.0080.01017.21
7.4.330.0030.00315.33
7.4.320.0000.00717.02
7.4.300.0070.00017.02
7.4.290.0060.00317.04
7.4.280.0030.00416.90
7.4.270.0050.00317.04
7.4.260.0030.00316.86
7.4.250.0000.00716.95
7.4.240.0060.00117.08
7.4.230.0000.00717.20
7.4.220.0030.01916.90
7.4.210.0060.01117.12
7.4.200.0030.00317.23
7.4.190.0000.00716.91
7.4.160.0120.00616.99
7.4.150.0160.00617.40
7.4.140.0080.01017.86
7.4.130.0070.01116.97
7.4.120.0130.00717.05
7.4.110.0100.00717.04
7.4.100.0120.00617.26
7.4.90.0040.01417.15
7.4.80.0110.00917.06
7.4.70.0000.01717.02
7.4.60.0090.01516.90
7.4.50.0060.00316.90
7.4.40.0070.01022.77
7.4.30.0140.01217.11
7.4.00.0050.01215.36
7.3.330.0000.00513.70
7.3.320.0060.00013.90
7.3.310.0070.00016.78
7.3.300.0000.00716.85
7.3.290.0080.00716.89
7.3.280.0090.00916.87
7.3.270.0090.00917.40
7.3.260.0090.00916.95
7.3.250.0070.01316.95
7.3.240.0130.00716.97
7.3.230.0120.00617.10
7.3.210.0090.01417.04
7.3.200.0110.00619.39
7.3.190.0110.00716.91
7.3.180.0070.01017.01
7.3.170.0090.00617.07
7.3.160.0070.01017.01
7.3.120.0050.00915.21
7.3.110.0070.01015.27
7.3.100.0050.00915.26
7.3.90.0100.00615.20
7.3.80.0060.01115.29
7.3.70.0090.00715.31
7.3.60.0050.00615.32
7.3.50.0070.01015.09
7.3.40.0070.00715.01
7.3.30.0040.00815.18
7.3.20.0050.00917.06
7.3.10.0060.00817.03
7.3.00.0060.00717.02
7.2.330.0100.00717.17
7.2.320.0030.01617.09
7.2.310.0060.01217.14
7.2.300.0070.01017.09
7.2.290.0110.00617.00
7.2.250.0080.00915.28
7.2.240.0090.01015.37
7.2.230.0050.01015.37
7.2.220.0040.00715.26
7.2.210.0050.00915.38
7.2.200.0120.00215.21
7.2.190.0050.00615.52
7.2.180.0100.00615.26
7.2.170.0060.01015.33
7.2.60.0100.00317.17
7.2.50.0030.01017.10
7.1.330.0040.01016.19
7.1.320.0030.01016.25
7.1.310.0080.00616.21
7.1.300.0040.00916.18
7.1.290.0030.01016.00
7.1.280.0030.00816.27
7.1.270.0080.00616.14
7.1.260.0070.00516.08
7.1.200.0200.01015.97
7.1.100.0060.00618.65
7.1.70.0070.00517.57
7.1.60.0150.00919.24
7.1.50.0000.01517.18
7.1.00.0030.07322.57
7.0.200.0120.00317.11
7.0.140.0030.07322.14
7.0.60.0200.04020.04
7.0.50.0130.03317.99
7.0.40.0070.06720.20
7.0.30.0430.06720.29
7.0.20.0130.05020.28
7.0.10.0130.08020.22
7.0.00.0030.08320.29
5.6.280.0070.07021.05
5.6.210.0030.04320.96
5.6.200.0100.06318.37
5.6.190.0070.07320.56
5.6.180.0330.05720.56
5.6.170.0430.07020.63
5.6.160.0030.05320.62
5.6.150.0070.08318.34
5.6.140.0070.07018.33
5.6.130.0130.06718.36
5.6.120.0000.05721.15
5.6.110.0030.04021.20
5.6.100.0100.03721.08
5.6.90.0070.08721.17
5.6.80.0030.05720.57
5.5.350.4330.04320.66
5.5.340.0170.05718.00
5.5.330.0030.06020.35
5.5.320.0630.06720.39
5.5.310.0300.07720.38
5.5.300.0130.07318.14
5.5.290.0130.03718.10
5.5.280.0130.07021.00
5.5.270.0270.07720.94
5.5.260.0100.06720.94
5.5.250.0100.04720.66
5.5.240.0070.07720.26
5.4.450.4200.04019.31
5.4.440.0030.08319.35
5.4.430.1330.05719.43
5.4.420.4100.04019.42
5.4.410.3400.04019.34
5.4.400.3600.04319.16
5.4.390.4400.04019.36
5.4.380.4230.03019.20
5.4.370.4430.04019.00
5.4.360.4030.03719.23
5.4.350.4030.03719.36
5.4.340.4330.04019.04
5.4.320.4170.03319.14
5.4.310.4530.03719.25
5.4.300.0170.06319.23
5.4.290.0070.05319.29
5.4.280.4500.03718.98
5.4.270.4500.04019.36
5.4.260.4670.03018.98
5.4.250.3600.04318.97
5.4.240.3930.03019.25
5.4.230.3430.05019.20
5.4.220.3900.03318.98
5.4.210.3900.04019.15
5.4.200.4230.04319.25
5.4.190.0000.05319.25
5.4.180.4530.03719.09
5.4.170.4330.04019.28
5.4.160.4170.03719.20
5.4.150.3730.05019.13
5.4.140.3970.02716.53
5.4.130.4070.03016.61
5.4.120.4070.03716.60
5.4.110.3470.03316.59
5.4.100.4670.03316.51
5.4.90.3670.03016.61
5.4.80.3630.03316.60
5.4.70.3300.03316.65
5.4.60.3570.03716.61
5.4.50.3600.03316.45
5.4.40.3570.03716.61
5.4.30.3630.04016.53
5.4.20.3170.04016.45
5.4.10.3630.02716.61
5.4.00.3900.03316.07
5.3.290.4330.04014.84
5.3.280.3600.04314.86
5.3.270.4400.03714.72
5.3.260.4370.04314.72
5.3.250.4530.04314.72
5.3.240.4170.03714.74
5.3.230.3970.04014.62
5.3.220.4400.04314.73
5.3.210.4200.04014.75
5.3.200.3900.03714.72
5.3.190.4030.03314.78
5.3.180.3630.03314.72
5.3.170.3570.04014.68
5.3.160.3630.03014.83
5.3.150.3730.04314.79
5.3.140.3670.03714.73
5.3.130.3630.03314.78
5.3.120.3400.03714.71
5.3.110.2430.02714.78
5.3.100.3630.03714.05
5.3.90.3670.03314.18
5.3.80.3670.03714.27
5.3.70.3700.03314.29
5.3.60.3930.02714.16
5.3.50.3770.04014.21
5.3.40.3900.03314.14
5.3.30.4570.03013.96
5.3.20.3700.03013.87
5.3.10.4130.03713.84
5.3.00.4000.04013.79
5.2.170.2970.03311.17
5.2.160.3170.02011.33
5.2.150.3800.03711.41
5.2.140.4130.03011.20
5.2.130.3530.03311.26
5.2.120.3930.02711.28
5.2.110.3830.02711.25
5.2.100.3800.03311.27
5.2.90.3470.03311.15
5.2.80.3600.02311.11
5.2.70.3600.03311.31
5.2.60.3530.02311.22
5.2.50.3900.02711.20
5.2.40.3070.02311.21
5.2.30.2830.03011.13
5.2.20.2930.02711.12
5.2.10.2630.03311.07
5.2.00.2400.03010.88
5.1.60.2700.02710.12
5.1.50.2300.02710.20
5.1.40.2430.02310.18
5.1.30.2700.03010.48
5.1.20.3330.02010.50
5.1.10.2870.02010.06
5.1.00.2730.02710.09
5.0.50.1970.0178.64
5.0.40.1770.0178.48
5.0.30.1670.0308.24
5.0.20.1470.0208.20
5.0.10.1430.0138.18
5.0.00.1770.0308.25
4.4.90.1530.0176.38
4.4.80.1770.0206.38
4.4.70.1630.0176.38
4.4.60.1870.0136.38
4.4.50.1530.0136.38
4.4.40.1530.0236.38
4.4.30.1430.0206.38
4.4.20.1330.0206.38
4.4.10.1770.0136.38
4.4.00.1770.0276.38
4.3.110.1730.0206.38
4.3.100.1730.0176.38
4.3.90.1530.0136.38
4.3.80.1470.0206.38
4.3.70.1200.0136.38
4.3.60.1230.0106.38
4.3.50.1230.0106.38
4.3.40.1170.0276.38
4.3.30.0570.0176.38
4.3.20.0670.0176.38
4.3.10.0600.0136.38
4.3.00.0570.0176.38

preferences:
56.17 ms | 401 KiB | 5 Q