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('/(<node>\w+)(<key>\[\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.0130.00317.00
8.3.50.0150.00616.95
8.3.40.0140.00319.34
8.3.30.0090.00919.28
8.3.20.0040.00419.23
8.3.10.0090.00019.27
8.3.00.0090.00019.88
8.2.180.0140.00318.91
8.2.170.0070.00722.96
8.2.160.0180.00021.15
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0080.00021.36
8.2.110.0030.00619.40
8.2.100.0040.00818.34
8.2.90.0050.00319.42
8.2.80.0030.00519.53
8.2.70.0070.00318.25
8.2.60.0040.00418.18
8.2.50.0000.00818.25
8.2.40.0040.00420.38
8.2.30.0030.00618.23
8.2.20.0130.00018.17
8.2.10.0040.00418.30
8.2.00.0030.00718.35
8.1.280.0120.00425.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0090.00024.09
8.1.230.0090.00321.30
8.1.220.0080.00018.77
8.1.210.0000.00819.08
8.1.200.0030.00717.97
8.1.190.0040.00417.72
8.1.180.0070.00318.10
8.1.170.0050.00319.14
8.1.160.0000.00819.24
8.1.150.0080.00018.95
8.1.140.0040.00417.83
8.1.130.0000.00718.21
8.1.120.0080.00017.88
8.1.110.0080.00017.96
8.1.100.0000.00817.79
8.1.90.0000.00717.82
8.1.80.0040.00417.88
8.1.70.0000.00717.89
8.1.60.0060.00317.92
8.1.50.0060.00317.88
8.1.40.0090.00017.97
8.1.30.0050.00517.99
8.1.20.0070.00318.04
8.1.10.0070.00017.97
8.1.00.0000.00817.87
8.0.300.0030.00620.25
8.0.290.0080.00017.09
8.0.280.0070.00018.73
8.0.270.0040.00417.59
8.0.260.0030.00317.36
8.0.250.0040.00417.44
8.0.240.0000.00717.35
8.0.230.0000.00717.35
8.0.220.0070.00017.44
8.0.210.0040.00417.35
8.0.200.0030.00317.45
8.0.190.0040.00417.37
8.0.180.0030.00617.31
8.0.170.0030.00617.29
8.0.160.0030.00517.42
8.0.150.0060.00317.32
8.0.140.0040.00717.40
8.0.130.0030.00313.88
8.0.120.0030.00817.27
8.0.110.0040.00417.27
8.0.100.0070.00017.28
8.0.90.0000.00717.34
8.0.80.0070.01117.46
8.0.70.0030.00517.29
8.0.60.0060.00317.47
8.0.50.0000.00817.41
8.0.30.0170.00317.73
8.0.20.0090.00917.59
8.0.10.0000.00717.38
8.0.00.0110.00817.03
7.4.330.0030.00313.44
7.4.320.0000.00617.03
7.4.300.0040.00416.93
7.4.290.0000.00717.08
7.4.280.0030.00517.05
7.4.270.0000.00817.15
7.4.260.0050.00013.77
7.4.250.0080.00016.96
7.4.240.0040.00417.00
7.4.230.0000.00716.74
7.4.220.0190.00316.99
7.4.210.0080.00817.18
7.4.200.0040.00417.16
7.4.190.0060.00317.09
7.4.160.0110.00616.91
7.4.150.0090.00916.99
7.4.140.0060.01216.83
7.4.130.0130.00617.12
7.4.120.0070.01017.04
7.4.110.0180.00616.98
7.4.100.0100.00716.89
7.4.90.0070.01116.93
7.4.80.0050.01319.39
7.4.70.0290.01217.01
7.4.60.0080.00917.00
7.4.50.0040.00017.19
7.4.40.0090.00616.98
7.4.30.0140.00316.93
7.4.00.0120.00315.29
7.3.330.0060.00013.86
7.3.320.0030.00313.85
7.3.310.0000.00716.95
7.3.300.0040.00416.76
7.3.290.0070.01116.89
7.3.280.0080.00716.85
7.3.270.0080.00917.14
7.3.260.0060.01217.04
7.3.250.0110.00916.91
7.3.240.0140.00316.93
7.3.230.0130.00316.92
7.3.210.0110.00816.85
7.3.200.0120.00617.00
7.3.190.0070.01117.02
7.3.180.0040.01217.10
7.3.170.0090.00916.80
7.3.160.0040.01417.06
7.3.120.0070.01015.12
7.2.330.0060.01216.82
7.2.320.0060.01217.25
7.2.310.0170.00017.18
7.2.300.0030.01317.26
7.2.290.0140.00317.07
7.2.80.0070.00716.98
7.2.60.0000.01517.19
7.2.00.0070.00719.68
7.1.200.0070.00716.15
7.1.100.0060.00318.44
7.1.70.0020.00517.37
7.1.60.0070.01619.30
7.1.50.0080.01517.12
7.1.00.0000.07322.51
7.0.200.0110.00417.09
7.0.140.0070.07022.18
7.0.120.0000.07722.19
7.0.60.0030.05020.16
7.0.50.0030.05718.07
7.0.40.0000.08318.00
7.0.30.0100.05717.90
7.0.20.0100.08717.89
7.0.10.0130.07317.89
7.0.00.0000.04717.82
5.6.280.0030.07721.04
5.6.210.0030.04020.60
5.6.200.0030.07718.34
5.6.190.0070.07018.39
5.6.180.0130.07318.36
5.6.170.0030.04318.31
5.6.160.0170.06318.33
5.6.150.0130.05018.27
5.6.140.0070.07718.41
5.6.130.0130.06718.39
5.6.120.0030.05718.27
5.6.110.0070.06318.30
5.6.100.0070.08018.36
5.6.90.0200.05318.24
5.6.80.0070.06717.66
5.6.70.0030.04017.76
5.6.60.0130.04017.70
5.6.50.0000.05017.72
5.6.40.0130.07317.75
5.6.30.0100.06717.79
5.6.20.0030.08317.72
5.6.10.0030.08717.74
5.6.00.0070.04317.75
5.5.350.0330.07320.56
5.5.340.0200.06718.12
5.5.330.0170.07318.15
5.5.320.0100.07318.16
5.5.310.0070.08018.12
5.5.300.0100.07718.09
5.5.290.0100.06718.20
5.5.280.0130.07318.04
5.5.270.0070.04718.16
5.5.260.0030.05718.18
5.5.250.0070.06317.90
5.5.240.0030.04017.45
5.5.230.0030.04017.54
5.5.220.0130.05017.54
5.5.210.0100.06717.41
5.5.200.0070.03717.52
5.5.190.0070.03717.54
5.5.180.0130.05717.39
5.5.160.0070.07017.39
5.5.150.0100.07317.52
5.5.140.0130.06717.45
5.5.130.0130.05717.48
5.5.120.0170.06717.41
5.5.110.0170.04317.34
5.5.100.0030.08317.47
5.5.90.0030.08717.46
5.5.80.0030.05017.34
5.5.70.0200.06017.31
5.5.60.0100.07017.31
5.5.50.0000.05717.34
5.5.40.0030.07017.39
5.5.30.0000.04317.28
5.5.20.0070.05317.23
5.5.10.0030.08317.43
5.5.00.0030.07317.23
5.4.450.0100.06319.48
5.4.440.0030.07319.53
5.4.430.0130.04719.47
5.4.420.0030.06319.45
5.4.410.0100.07319.46
5.4.400.0000.06319.20
5.4.390.0030.05319.03
5.4.380.0030.05019.35
5.4.370.0030.05719.11
5.4.360.0030.05719.25
5.4.350.0100.07319.03
5.4.340.0070.08019.22
5.4.320.0070.05019.11
5.4.310.0030.04019.13
5.4.300.0100.07319.12
5.4.290.0130.06319.21
5.4.280.0130.07318.98
5.4.270.0100.07319.24
5.4.260.0100.07319.23
5.4.250.0100.07719.21
5.4.240.0030.07319.20
5.4.230.0000.04719.20
5.4.220.0070.04319.13
5.4.210.0130.05019.13
5.4.200.0130.05719.27
5.4.190.0100.06019.26
5.4.180.0100.07019.02
5.4.170.0070.05019.20
5.4.160.0100.07719.18
5.4.150.0070.05319.21
5.4.140.0070.06016.59
5.4.130.0100.06716.52
5.4.120.0030.05316.50
5.4.110.0030.04716.67
5.4.100.0030.03716.71
5.4.90.0030.03716.55
5.4.80.0030.03716.50
5.4.70.0100.03316.65
5.4.60.0030.03316.51
5.4.50.0000.03716.69
5.4.40.0070.03316.59
5.4.30.0030.03316.59
5.4.20.0000.03716.55
5.4.10.0100.03016.57
5.4.00.0070.03715.97
5.3.290.0070.07714.73
5.3.280.0030.05714.76
5.3.270.0030.05314.70
5.3.260.0000.04314.66
5.3.250.0100.03714.76
5.3.240.0070.06714.86
5.3.230.0070.05314.65
5.3.220.0070.06314.70
5.3.210.0070.05714.66
5.3.200.0030.03714.79
5.3.190.0000.04314.71
5.3.180.0070.03714.70
5.3.170.0070.03314.87
5.3.160.0030.03714.72
5.3.150.0100.04714.87
5.3.140.0070.03314.63
5.3.130.0000.04014.72
5.3.120.0100.03014.68
5.3.110.0030.03714.77
5.3.100.0100.03314.34
5.3.90.0030.03314.07
5.3.80.0030.03314.17
5.3.70.0070.03314.18
5.3.60.0000.03714.14
5.3.50.0000.03713.94
5.3.40.0030.03714.16
5.3.30.0000.03714.10
5.3.20.0070.03013.77
5.3.10.0070.03013.75
5.3.00.0070.03313.82
5.2.170.0030.02711.32
5.2.160.0030.02711.37
5.2.150.0000.03711.32
5.2.140.0000.03011.31
5.2.130.0070.02711.20
5.2.120.0100.02311.10
5.2.110.0030.02711.41
5.2.100.0030.02711.36
5.2.90.0030.02711.27
5.2.80.0070.03311.30
5.2.70.0000.03011.09
5.2.60.0000.03011.18
5.2.50.0000.03011.10
5.2.40.0070.02311.17
5.2.30.0030.02711.29
5.2.20.0030.02711.12
5.2.10.0000.04310.86
5.2.00.0070.02311.00
5.1.60.0030.02310.13
5.1.50.0070.04710.09
5.1.40.0000.02710.14
5.1.30.0030.02710.46
5.1.20.0000.02710.43
5.1.10.0000.03310.04
5.1.00.0070.02010.14
5.0.50.0070.0178.51
5.0.40.0030.0408.38
5.0.30.0000.0508.22
5.0.20.0030.0438.30
5.0.10.0000.0338.17
5.0.00.0030.0308.15
4.4.90.0000.0138.09
4.4.80.0000.0138.09
4.4.70.0000.0208.09
4.4.60.0070.0108.09
4.4.50.0000.0208.09
4.4.40.0100.0478.09
4.4.30.0030.0178.09
4.4.20.0000.0178.09
4.4.10.0000.0138.09
4.4.00.0000.0338.09
4.3.110.0000.0178.09
4.3.100.0000.0208.09
4.3.90.0000.0378.09
4.3.80.0000.0278.09
4.3.70.0000.0178.09
4.3.60.0000.0238.09
4.3.50.0000.0178.09
4.3.40.0030.0438.09
4.3.30.0070.0278.09
4.3.20.0000.0278.09
4.3.10.0000.0408.09
4.3.00.0000.0208.09

preferences:
47.82 ms | 401 KiB | 5 Q