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 (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.0040.01117.13
8.3.50.0080.01122.27
8.3.40.0120.00619.42
8.3.30.0040.01119.47
8.3.20.0040.00420.45
8.3.10.0050.00323.95
8.3.00.0040.00422.66
8.2.180.0040.01517.00
8.2.170.0070.00722.96
8.2.160.0090.00620.63
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0050.00322.46
8.2.110.0090.00022.58
8.2.100.0040.00818.28
8.2.90.0000.00819.56
8.2.80.0000.00818.18
8.2.70.0030.00718.13
8.2.60.0030.00618.18
8.2.50.0030.00518.07
8.2.40.0080.00019.64
8.2.30.0000.00818.39
8.2.20.0000.00818.16
8.2.10.0050.00320.05
8.2.00.0030.00618.21
8.1.280.0070.00725.92
8.1.270.0040.00422.39
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0040.00424.08
8.1.230.0120.00019.60
8.1.220.0000.00818.03
8.1.210.0000.00918.77
8.1.200.0040.01317.85
8.1.190.0080.00017.89
8.1.180.0060.00318.10
8.1.170.0060.00318.97
8.1.160.0000.00822.31
8.1.150.0040.00419.02
8.1.140.0000.00717.94
8.1.130.0070.00018.11
8.1.120.0030.00517.95
8.1.110.0030.00517.82
8.1.100.0070.00017.94
8.1.90.0000.00817.95
8.1.80.0030.00317.95
8.1.70.0070.00017.84
8.1.60.0040.00418.01
8.1.50.0030.00518.00
8.1.40.0030.00517.93
8.1.30.0040.00417.94
8.1.20.0000.00817.97
8.1.10.0060.00317.89
8.1.00.0080.00317.76
8.0.300.0000.00718.77
8.0.290.0040.00417.43
8.0.280.0040.00418.61
8.0.270.0000.00817.55
8.0.260.0000.00717.31
8.0.250.0000.00717.36
8.0.240.0030.00517.36
8.0.230.0040.00417.34
8.0.220.0030.00317.28
8.0.210.0030.00717.25
8.0.200.0040.00417.43
8.0.190.0030.00617.48
8.0.180.0040.00417.45
8.0.170.0030.00617.46
8.0.160.0040.00417.41
8.0.150.0000.00817.33
8.0.140.0000.00717.39
8.0.130.0000.00813.77
8.0.120.0080.00017.31
8.0.110.0030.00617.28
8.0.100.0050.00317.41
8.0.90.0030.00517.20
8.0.80.0100.01017.39
8.0.70.0000.00717.43
8.0.60.0040.00417.44
8.0.50.0020.00517.42
8.0.30.0090.01017.46
8.0.20.0030.01517.50
8.0.10.0040.00417.50
8.0.00.0120.00717.10
7.4.330.0000.00515.27
7.4.320.0000.00717.13
7.4.300.0030.00317.00
7.4.290.0000.00717.04
7.4.280.0030.00417.00
7.4.270.0030.00617.04
7.4.260.0030.00317.11
7.4.250.0000.00717.08
7.4.240.0050.00217.01
7.4.230.0000.00717.21
7.4.220.0140.01417.08
7.4.210.0090.00617.08
7.4.200.0040.00417.19
7.4.190.0040.00416.92
7.4.160.0160.00017.22
7.4.150.0140.00717.40
7.4.140.0180.00317.86
7.4.130.0090.01017.13
7.4.120.0110.00617.12
7.4.110.0070.01317.24
7.4.100.0110.00717.05
7.4.90.0110.00617.02
7.4.80.0140.00319.39
7.4.70.0130.00716.89
7.4.60.0140.00417.05
7.4.50.0050.00317.08
7.4.40.0090.00922.77
7.4.30.0090.00916.94
7.4.00.0100.00715.23
7.3.330.0040.00413.85
7.3.320.0030.00313.85
7.3.310.0070.00016.91
7.3.300.0030.00316.83
7.3.290.0120.00316.87
7.3.280.0100.00916.85
7.3.270.0030.01317.40
7.3.260.0100.00717.12
7.3.250.0080.01016.97
7.3.240.0000.01716.81
7.3.230.0170.00417.05
7.3.210.0070.01116.98
7.3.200.0050.01919.39
7.3.190.0030.01517.00
7.3.180.0160.00617.18
7.3.170.0100.01016.87
7.3.160.0160.00716.90
7.3.120.0090.00615.44
7.2.330.0030.01417.27
7.2.320.0090.00917.26
7.2.310.0140.00317.02
7.2.300.0100.00716.93
7.2.290.0070.01017.12
7.2.60.0070.01017.13
7.2.00.0030.01019.86
7.1.200.0000.01016.18
7.1.100.0000.01118.64
7.1.70.0070.00317.45
7.1.60.0200.00319.29
7.1.50.0130.01017.28
7.1.00.0030.07322.58
7.0.200.0030.00716.75
7.0.140.0200.06022.18
7.0.60.0130.08020.18
7.0.50.0100.07318.10
7.0.40.0100.08020.39
7.0.30.0300.08320.32
7.0.20.0300.07020.30
7.0.10.0370.07320.34
7.0.00.0000.06720.29
5.6.280.0070.07321.19
5.6.210.0070.08020.64
5.6.200.0070.08018.21
5.6.190.0070.08720.60
5.6.180.0000.07020.82
5.6.170.0300.07020.71
5.6.160.0030.04020.57
5.6.150.0130.07318.31
5.6.140.0130.07018.36
5.6.130.0130.05018.41
5.6.120.0070.08321.04
5.6.110.0030.09021.22
5.6.100.0000.07321.20
5.6.90.0070.08021.00
5.6.80.0030.08320.48
5.6.70.0230.03320.59
5.5.350.0030.08720.51
5.5.340.0030.04318.16
5.5.330.0130.06720.54
5.5.320.0030.06020.48
5.5.310.0230.08320.49
5.5.300.0030.07718.11
5.5.290.0070.04718.11
5.5.280.0070.09020.88
5.5.270.0070.06320.87
5.5.260.0170.05020.94
5.5.250.0070.08320.72
5.5.240.0130.06320.27
5.4.450.1170.05019.55
5.4.440.0630.06019.48
5.4.430.0570.06019.55
5.4.420.0530.05719.75
5.4.410.0230.05719.09
5.4.400.0270.06318.88
5.4.390.0200.05018.68
5.4.380.0270.06718.96
5.4.370.0100.06018.56
5.4.360.0230.04718.75
5.4.350.0130.05718.83
5.4.340.0070.06318.90
5.4.320.0080.04412.70
5.4.310.0090.03812.69
5.4.300.0040.03812.70
5.4.290.0080.04412.70
5.4.280.0050.03712.59
5.4.270.0060.03912.59
5.4.260.0110.03512.60
5.4.250.0080.04412.59
5.4.240.0120.03112.59
5.4.230.0060.04112.59
5.4.220.0050.04812.59
5.4.210.0090.03912.59
5.4.200.0100.03712.58
5.4.190.0180.04112.57
5.4.180.0120.04812.57
5.4.170.0140.04512.59
5.4.160.0180.04512.58
5.4.150.0140.04812.57
5.4.140.0200.04112.26
5.4.130.0160.04612.25
5.4.120.0150.04912.20
5.4.110.0210.04412.20
5.4.100.0150.04912.20
5.4.90.0150.04612.20
5.4.80.0170.04512.20
5.4.70.0150.04412.20
5.4.60.0180.04312.20
5.4.50.0170.04212.19
5.4.40.0180.04112.18
5.4.30.0180.04212.18
5.4.20.0180.03912.17
5.4.10.0200.04012.17
5.4.00.0150.04111.67
5.3.290.0050.04212.96
5.3.280.0050.03812.89
5.3.270.0150.04812.88
5.3.260.0180.04512.88
5.3.250.0180.04212.88
5.3.240.0150.04612.88
5.3.230.0100.05212.87
5.3.220.0140.04912.85
5.3.210.0190.04212.85
5.3.200.0130.05112.84
5.3.190.0230.03912.84
5.3.180.0220.03812.84
5.3.170.0180.04312.84
5.3.160.0180.04312.84
5.3.150.0160.04512.84
5.3.140.0180.04212.83
5.3.130.0190.04212.82
5.3.120.0150.04812.84
5.3.110.0200.04212.83
5.3.100.0160.04512.33
5.3.90.0190.04312.29
5.3.80.0200.04412.29
5.3.70.0160.05112.29
5.3.60.0170.04512.27
5.3.50.0200.04012.21
5.3.40.0160.04412.21
5.3.30.0140.04512.18
5.3.20.0230.03811.95
5.3.10.0140.04411.92
5.3.00.0140.04311.91
5.2.170.0160.0339.42
5.2.160.0140.0339.42
5.2.150.0150.0359.42
5.2.140.0170.0349.42
5.2.130.0150.0329.38
5.2.120.0130.0349.38
5.2.110.0110.0379.38
5.2.100.0150.0339.38
5.2.90.0120.0399.38
5.2.80.0140.0369.38
5.2.70.0150.0349.37
5.2.60.0140.0349.33
5.2.50.0140.0379.29
5.2.40.0170.0329.27
5.2.30.0100.0389.25
5.2.20.0110.0419.24
5.2.10.0130.0349.13
5.2.00.0120.0348.99
5.1.60.0160.0258.29
5.1.50.0130.0298.28
5.1.40.0110.0298.27
5.1.30.0090.0348.61
5.1.20.0090.0348.60
5.1.10.0120.0328.16
5.1.00.0090.0338.16
5.0.50.0090.0256.65
5.0.40.0080.0276.51
5.0.30.0080.0376.32
5.0.20.0090.0246.29
5.0.10.0080.0246.27
5.0.00.0070.0386.26
4.4.90.0070.0184.78
4.4.80.0080.0194.76
4.4.70.0090.0174.75
4.4.60.0110.0164.76
4.4.50.0070.0194.77
4.4.40.0130.0554.71
4.4.30.0090.0194.76
4.4.20.0100.0174.84
4.4.10.0080.0214.85
4.4.00.0080.0294.75
4.3.110.0090.0204.67
4.3.100.0070.0214.66
4.3.90.0100.0214.63
4.3.80.0120.0264.58
4.3.70.0090.0184.63
4.3.60.0090.0184.63
4.3.50.0090.0194.63
4.3.40.0080.0364.54
4.3.30.0070.0213.30
4.3.20.0040.0223.27
4.3.10.0060.0193.24
4.3.00.0000.02013.64

preferences:
46.59 ms | 401 KiB | 5 Q