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); var_dump($test = $this->xml->xpath('/note/recursive/val'), $test[1]);die; } 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 . '[' . $offset . ']'); $target = $target[0]; return new self($target->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']; echo $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.0110.00717.13
8.3.50.0060.01022.14
8.3.40.0150.00019.40
8.3.30.0070.00719.42
8.3.20.0160.00320.54
8.3.10.0050.00322.42
8.3.00.0080.00022.82
8.2.180.0110.00717.00
8.2.170.0110.00422.96
8.2.160.0040.01121.62
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0090.00626.16
8.2.120.0050.00319.86
8.2.110.0030.00720.95
8.2.100.0000.01220.08
8.2.90.0060.00318.66
8.2.80.0030.00618.30
8.2.70.0090.00018.13
8.2.60.0030.00618.40
8.2.50.0080.00018.07
8.2.40.0030.00618.53
8.2.30.0030.00518.64
8.2.20.0040.00418.09
8.2.10.0080.00018.32
8.2.00.0050.00318.13
8.1.280.0130.00325.92
8.1.270.0030.00624.29
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.52
8.1.230.0080.00421.39
8.1.220.0060.00318.14
8.1.210.0000.00919.31
8.1.200.0030.00717.85
8.1.190.0090.00018.03
8.1.180.0060.00318.10
8.1.170.0030.00619.01
8.1.160.0060.00322.39
8.1.150.0090.00019.01
8.1.140.0040.00417.88
8.1.130.0040.00418.15
8.1.120.0000.00817.97
8.1.110.0040.00417.87
8.1.100.0000.00817.85
8.1.90.0000.00717.91
8.1.80.0000.00717.87
8.1.70.0040.00417.88
8.1.60.0000.00817.97
8.1.50.0030.00517.77
8.1.40.0000.00817.94
8.1.30.0060.00317.95
8.1.20.0030.00517.84
8.1.10.0030.00618.07
8.1.00.0080.00017.80
8.0.300.0040.00420.70
8.0.290.0040.00417.55
8.0.280.0000.00718.79
8.0.270.0040.00417.61
8.0.260.0000.00718.81
8.0.250.0030.00617.37
8.0.240.0050.00317.41
8.0.230.0030.00317.48
8.0.220.0030.00317.41
8.0.210.0040.00417.37
8.0.200.0000.00617.48
8.0.190.0000.00817.26
8.0.180.0040.00417.27
8.0.170.0050.00317.17
8.0.160.0030.00617.40
8.0.150.0000.00717.38
8.0.140.0040.00417.30
8.0.130.0000.00913.86
8.0.120.0030.00617.30
8.0.110.0040.00417.45
8.0.100.0020.00517.27
8.0.90.0080.00017.38
8.0.80.0070.01017.30
8.0.70.0040.00417.22
8.0.60.0000.00717.20
8.0.50.0000.00717.30
8.0.30.0100.01117.59
8.0.20.0090.01117.56
8.0.10.0050.00317.50
8.0.00.0140.00617.13
7.4.330.0060.00015.41
7.4.320.0070.00016.93
7.4.300.0030.00317.03
7.4.290.0030.00316.98
7.4.280.0050.00516.77
7.4.270.0090.00016.97
7.4.260.0040.00416.94
7.4.250.0000.00816.95
7.4.240.0010.00717.03
7.4.230.0000.00816.90
7.4.220.0070.01016.82
7.4.210.0070.01116.95
7.4.200.0040.00416.96
7.4.190.0000.00717.06
7.4.160.0030.01417.09
7.4.150.0070.01017.40
7.4.140.0120.01017.86
7.4.130.0070.00916.97
7.4.120.0060.01216.91
7.4.110.0090.00916.91
7.4.100.0180.00416.81
7.4.90.0110.00716.93
7.4.80.0080.01416.89
7.4.70.0100.00717.03
7.4.60.0000.01817.02
7.4.50.0080.00017.05
7.4.40.0100.00322.77
7.4.30.0100.00717.12
7.4.00.0030.01415.15
7.3.330.0000.00613.77
7.3.320.0000.00513.80
7.3.310.0000.00716.94
7.3.300.0040.00416.91
7.3.290.0040.01716.70
7.3.280.0110.00516.75
7.3.270.0090.00917.40
7.3.260.0170.00716.93
7.3.250.0090.00916.83
7.3.240.0100.00716.85
7.3.230.0140.00716.95
7.3.210.0120.00617.00
7.3.200.0160.00619.39
7.3.190.0100.01016.86
7.3.180.0080.00816.88
7.3.170.0100.00716.89
7.3.160.0080.00816.88
7.3.120.0090.00615.04
7.2.330.0090.01217.01
7.2.320.0150.01116.96
7.2.310.0000.01716.92
7.2.300.0070.01117.20
7.2.290.0170.00017.29
7.2.60.0030.01316.97
7.2.00.0030.01119.82
7.1.200.0140.00915.31
7.1.100.0030.00718.32
7.1.70.0080.00817.44
7.1.60.0040.02219.82
7.1.50.0140.00716.73
7.1.00.0030.07022.70
7.0.200.0060.00616.88
7.0.140.0070.07022.22
7.0.60.0100.08020.22
7.0.50.0070.04718.14
7.0.40.0130.08020.32
7.0.30.0530.07020.27
7.0.20.0270.08020.33
7.0.10.0070.04320.27
7.0.00.0130.06320.36
5.6.280.0070.07021.15
5.6.210.0070.08020.75
5.6.200.0100.08318.44
5.6.190.0030.09020.71
5.6.180.4200.04320.58
5.6.170.0170.05320.68
5.6.160.0130.06320.75
5.6.150.0070.04018.40
5.6.140.0070.08318.30
5.6.130.0030.04018.45
5.6.120.0100.08021.26
5.6.110.0000.08721.21
5.6.100.0170.07721.16
5.6.90.0030.04321.30
5.6.80.0030.07020.61
5.5.350.0330.07320.53
5.5.340.0030.05718.19
5.5.330.0000.05020.48
5.5.320.0300.05020.57
5.5.310.0170.05020.49
5.5.300.0100.08318.13
5.5.290.0070.07318.16
5.5.280.0070.07721.10
5.5.270.0030.07321.10
5.5.260.0070.09020.93
5.5.250.0070.08020.79
5.5.240.4130.03720.38
5.4.450.0330.04319.70
5.4.440.0530.04719.54
5.4.430.0570.04019.62
5.4.420.0370.04319.44
5.4.410.0070.05719.23
5.4.400.0100.07319.07
5.4.390.0030.05719.01
5.4.380.0400.06318.98
5.4.370.0300.05318.98
5.4.360.0230.05718.67
5.4.350.0400.04318.96
5.4.340.0330.05719.03
5.4.320.0110.05112.75
5.4.310.0090.03912.75
5.4.300.0070.05012.75
5.4.290.0070.03912.75
5.4.280.0050.03812.65
5.4.270.0090.04212.64
5.4.260.0050.04412.64
5.4.250.0080.05112.64
5.4.240.0080.03312.64
5.4.230.0060.04312.64
5.4.220.0080.05012.64
5.4.210.0050.03712.64
5.4.200.0060.04112.64
5.4.190.0170.04212.62
5.4.180.0160.04612.61
5.4.170.0200.04412.62
5.4.160.0210.04812.62
5.4.150.0160.04612.62
5.4.140.0240.06512.30
5.4.130.0170.04512.29
5.4.120.0130.04512.25
5.4.110.0120.05012.24
5.4.100.0120.04812.24
5.4.90.0160.04512.24
5.4.80.0140.05112.24
5.4.70.0170.03912.24
5.4.60.0180.04612.24
5.4.50.0160.04812.24
5.4.40.0140.04312.23
5.4.30.0140.04812.23
5.4.20.0130.04412.23
5.4.10.0160.04112.23
5.4.00.0310.08611.71
5.3.290.0030.04213.02
5.3.280.0080.05112.95
5.3.270.0170.04812.93
5.3.260.0160.04612.93
5.3.250.0180.04212.93
5.3.240.0250.06612.93
5.3.230.0200.04312.92
5.3.220.0180.04112.89
5.3.210.0170.04612.89
5.3.200.0190.04312.89
5.3.190.0200.04812.89
5.3.180.0230.04812.89
5.3.170.0090.05212.88
5.3.160.0140.04712.89
5.3.150.0160.04412.89
5.3.140.0220.04212.88
5.3.130.0220.03912.87
5.3.120.0260.07412.87
5.3.110.0110.05312.88
5.3.100.0220.04412.36
5.3.90.0170.04312.34
5.3.80.0150.04712.33
5.3.70.0160.04912.33
5.3.60.0160.04612.31
5.3.50.0490.10412.27
5.3.40.0220.04712.26
5.3.30.0170.05012.22
5.3.20.0450.08912.00
5.3.10.0140.04311.98
5.3.00.0180.03911.96
5.2.170.0140.0349.46
5.2.160.0250.0839.46
5.2.150.0160.0329.46
5.2.140.0120.0359.45
5.2.130.0120.0349.42
5.2.120.0120.0349.41
5.2.110.0120.0359.42
5.2.100.0120.0349.42
5.2.90.0100.0369.42
5.2.80.0150.0359.41
5.2.70.0110.0399.41
5.2.60.0150.0339.38
5.2.50.0150.0329.34
5.2.40.0130.0359.32
5.2.30.0120.0349.29
5.2.20.0180.0619.27
5.2.10.0110.0379.17
5.2.00.0160.0369.04
5.1.60.0160.0268.32
5.1.50.0080.0328.32
5.1.40.0100.0298.31
5.1.30.0120.0328.66
5.1.20.0080.0358.67
5.1.10.0120.0308.17
5.1.00.0150.0318.17
5.0.50.0090.0256.66
5.0.40.0130.0186.52
5.0.30.0110.0346.32
5.0.20.0070.0246.30
5.0.10.0050.0266.28
5.0.00.0050.0406.27
4.4.90.0080.0174.78
4.4.80.0060.0194.75
4.4.70.0060.0214.75
4.4.60.0090.0174.75
4.4.50.0070.0184.77
4.4.40.0050.0314.70
4.4.30.0070.0194.76
4.4.20.0080.0174.85
4.4.10.0060.0194.85
4.4.00.0090.0264.76
4.3.110.0060.0194.67
4.3.100.0050.0194.67
4.3.90.0060.0184.63
4.3.80.0080.0264.58
4.3.70.0040.0204.63
4.3.60.0090.0154.63
4.3.50.0090.0204.63
4.3.40.0050.0294.54
4.3.30.0070.0163.30
4.3.20.0030.0203.28
4.3.10.0030.0193.24
4.3.00.0030.01313.29

preferences:
47.67 ms | 400 KiB | 5 Q