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 (is_int($offset)) { $tag = $this->xml->getName(); $target = $this->xml->xpath('../' . $tag); $target = $target[$offset]; return new self($target->asXML(), false); } if ('val1' == $offset) { var_dump((array)$this->xml->$offset);die; } return (array) $this->xml->$offset;//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'];

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.0070.01117.00
8.3.50.0070.01222.07
8.3.40.0040.01119.04
8.3.30.0090.00619.43
8.3.20.0050.00320.41
8.3.10.0000.00823.73
8.3.00.0050.00320.64
8.2.180.0150.00417.13
8.2.170.0110.00422.96
8.2.160.0110.00322.33
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0060.00322.49
8.2.110.0090.00022.30
8.2.100.0040.00818.09
8.2.90.0080.00019.47
8.2.80.0060.00318.18
8.2.70.0030.00617.63
8.2.60.0040.00418.04
8.2.50.0040.00418.07
8.2.40.0030.00618.59
8.2.30.0000.00818.35
8.2.20.0050.00318.02
8.2.10.0080.00018.01
8.2.00.0040.00418.05
8.1.280.0150.00625.92
8.1.270.0050.00324.14
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0060.00324.06
8.1.230.0080.00319.35
8.1.220.0040.00417.91
8.1.210.0030.00518.77
8.1.200.0060.00317.48
8.1.190.0050.00317.66
8.1.180.0090.00018.10
8.1.170.0080.00018.70
8.1.160.0070.00022.20
8.1.150.0080.00018.77
8.1.140.0040.00417.68
8.1.130.0000.00717.99
8.1.120.0040.00417.63
8.1.110.0040.00417.56
8.1.100.0040.00417.74
8.1.90.0000.00917.56
8.1.80.0000.00717.58
8.1.70.0000.00717.55
8.1.60.0030.00617.79
8.1.50.0030.00517.77
8.1.40.0030.00517.77
8.1.30.0090.00017.77
8.1.20.0030.00517.71
8.1.10.0040.00417.86
8.1.00.0050.00317.64
8.0.300.0000.00718.77
8.0.290.0040.00417.43
8.0.280.0070.00018.73
8.0.270.0050.00317.38
8.0.260.0030.00317.05
8.0.250.0040.00417.23
8.0.240.0040.00417.21
8.0.230.0040.00417.30
8.0.220.0030.00317.07
8.0.210.0040.00417.14
8.0.200.0030.00317.11
8.0.190.0040.00417.14
8.0.180.0050.00317.11
8.0.170.0030.00517.16
8.0.160.0050.00217.18
8.0.150.0040.00417.10
8.0.140.0000.00717.10
8.0.130.0030.00313.70
8.0.120.0000.00817.18
8.0.110.0040.00417.09
8.0.100.0000.00817.25
8.0.90.0040.00417.20
8.0.80.0030.01917.08
8.0.70.0040.00417.24
8.0.60.0040.00417.06
8.0.50.0040.00417.04
8.0.30.0100.00817.33
8.0.20.0100.01017.47
8.0.10.0040.00417.21
8.0.00.0090.01217.02
7.4.330.0050.00015.28
7.4.320.0030.00316.76
7.4.300.0060.00016.80
7.4.290.0000.00716.85
7.4.280.0000.00716.78
7.4.270.0000.00916.85
7.4.260.0000.00716.77
7.4.250.0080.00016.65
7.4.240.0020.00516.77
7.4.230.0030.00316.66
7.4.220.0130.00616.86
7.4.210.0090.00916.80
7.4.200.0030.00316.84
7.4.190.0030.00316.63
7.4.160.0120.00616.96
7.4.150.0060.01217.40
7.4.140.0070.01117.86
7.4.130.0070.01116.75
7.4.120.0100.00816.85
7.4.110.0070.01016.76
7.4.100.0180.00016.73
7.4.90.0180.00016.92
7.4.80.0100.01019.39
7.4.70.0120.00616.82
7.4.60.0070.01016.61
7.4.50.0040.00416.75
7.4.40.0030.01422.77
7.4.30.0100.00716.73
7.4.00.0090.00914.93
7.3.330.0000.00713.49
7.3.320.0030.00313.52
7.3.310.0070.00016.60
7.3.300.0030.00316.51
7.3.290.0070.01416.64
7.3.280.0100.00916.66
7.3.270.0060.01117.40
7.3.260.0170.00716.68
7.3.250.0130.01116.79
7.3.240.0080.00816.70
7.3.230.0070.01016.75
7.3.210.0130.00616.82
7.3.200.0110.01219.39
7.3.190.0060.01616.71
7.3.180.0090.00716.79
7.3.170.0100.01316.73
7.3.160.0060.00916.89
7.3.120.0050.01215.04
7.3.110.0080.00614.80
7.3.100.0060.01214.91
7.3.90.0040.00814.98
7.3.80.0060.01215.29
7.3.70.0060.00915.05
7.3.60.0040.00815.08
7.3.50.0030.00614.93
7.3.40.0060.00914.92
7.3.30.0030.01014.90
7.3.20.0100.00316.69
7.3.10.0070.00416.57
7.3.00.0050.00816.88
7.2.330.0170.00016.79
7.2.320.0150.00617.04
7.2.310.0110.01116.92
7.2.300.0150.00416.71
7.2.290.0040.01216.76
7.2.250.0070.01015.30
7.2.240.0100.01015.05
7.2.230.0000.01515.59
7.2.220.0040.01115.48
7.2.210.0030.01215.26
7.2.200.0040.01414.91
7.2.190.0060.00915.19
7.2.180.0100.00315.09
7.2.170.0090.00315.38
7.2.130.0080.00517.11
7.2.120.0000.01516.88
7.2.110.0070.00716.86
7.2.100.0030.00517.04
7.2.90.0070.00716.67
7.2.80.0060.00916.95
7.2.70.0110.00016.89
7.2.60.0090.00716.66
7.2.50.0120.00617.07
7.2.40.0160.00017.20
7.2.30.0060.00616.96
7.2.20.0100.00316.84
7.2.10.0090.00616.71
7.2.00.0000.01218.25
7.1.330.0000.01516.05
7.1.320.0060.00316.14
7.1.310.0040.01215.76
7.1.300.0080.00515.98
7.1.290.0000.01415.82
7.1.280.0060.00915.71
7.1.270.0030.01015.72
7.1.260.0070.00715.83
7.1.250.0080.00315.86
7.1.100.0000.00918.18
7.1.70.0040.00417.42
7.1.60.0060.01919.29
7.1.50.0170.00717.11
7.1.00.0030.07722.51
7.0.200.0090.00617.01
7.0.140.0000.07722.15
7.0.60.0200.06720.14
7.0.50.0130.03317.94
7.0.40.0100.03720.12
7.0.30.0200.08320.20
7.0.20.0270.07020.21
7.0.10.0030.07320.37
7.0.00.0030.08020.30
5.6.280.0030.07320.89
5.6.210.0000.06720.82
5.6.200.0100.03318.36
5.6.190.0130.07720.80
5.6.180.0500.07020.81
5.6.170.0230.08020.66
5.6.160.0000.05720.52
5.6.150.0100.07718.36
5.6.140.0030.04018.19
5.6.130.0100.07718.24
5.6.120.0100.06320.95
5.6.110.0130.06021.11
5.6.100.0030.07021.19
5.6.90.0170.05721.16
5.6.80.0130.07020.44
5.5.350.0230.05020.43
5.5.340.0130.07018.15
5.5.330.0170.04320.57
5.5.320.0270.08720.38
5.5.310.0300.04320.33
5.5.300.0130.06318.07
5.5.290.0100.04018.00
5.5.280.0200.06021.02
5.5.270.0070.08020.84
5.5.260.0130.07321.02
5.5.250.0070.04020.61
5.5.240.0170.07720.32
5.4.450.1070.03319.55
5.4.440.0700.05019.63
5.4.430.0830.03319.45
5.4.420.0870.04019.53
5.4.410.0800.05019.31
5.4.400.1000.05319.21
5.4.390.0770.04019.21
5.4.380.0400.06018.84
5.4.370.0530.05718.55
5.4.360.0430.05018.92
5.4.350.0330.05718.82
5.4.340.0370.05318.61
5.4.320.0060.03712.67
5.4.310.0120.04312.66
5.4.300.0070.04112.66
5.4.290.0050.04112.65
5.4.280.0050.04912.55
5.4.270.0070.03912.55
5.4.260.0080.03912.55
5.4.250.0040.05012.55
5.4.240.0070.03412.55
5.4.230.0060.04512.54
5.4.220.0080.03512.55
5.4.210.0060.03612.55
5.4.200.0060.03712.55
5.4.190.0180.04212.54
5.4.180.0150.04612.54
5.4.170.0140.04412.55
5.4.160.0150.04712.54
5.4.150.0240.06612.54
5.4.140.0110.04612.22
5.4.130.0170.04412.21
5.4.120.0170.04212.17
5.4.110.0160.04012.16
5.4.100.0220.07012.16
5.4.90.0180.04012.16
5.4.80.0240.06412.17
5.4.70.0190.03712.16
5.4.60.0180.03912.16
5.4.50.0130.04312.16
5.4.40.0180.07012.15
5.4.30.0170.04112.15
5.4.20.0130.04412.15
5.4.10.0140.04312.15
5.4.00.0140.04411.63
5.3.290.0080.04212.93
5.3.280.0080.03612.86
5.3.270.0110.05012.85
5.3.260.0170.04412.85
5.3.250.0240.06612.85
5.3.240.0170.04212.85
5.3.230.0150.04712.84
5.3.220.0160.04312.82
5.3.210.0120.04812.81
5.3.200.0190.04012.81
5.3.190.0160.04412.81
5.3.180.0180.04212.80
5.3.170.0180.04112.81
5.3.160.0140.04512.81
5.3.150.0130.04612.81
5.3.140.0120.04712.80
5.3.130.0130.04712.79
5.3.120.0160.07412.79
5.3.110.0150.04512.79
5.3.100.0120.05012.28
5.3.90.0130.04612.26
5.3.80.0190.04212.26
5.3.70.0130.04912.25
5.3.60.0160.04412.23
5.3.50.0160.04412.19
5.3.40.0130.04912.18
5.3.30.0140.04312.15
5.3.20.0150.04311.92
5.3.10.0110.04611.89
5.3.00.0150.04111.88
5.2.170.0110.0379.38
5.2.160.0270.0829.37
5.2.150.0160.0379.38
5.2.140.0120.0359.37
5.2.130.0130.0339.34
5.2.120.0140.0329.33
5.2.110.0170.0319.34
5.2.100.0210.0589.34
5.2.90.0120.0379.33
5.2.80.0160.0339.32
5.2.70.0130.0339.33
5.2.60.0130.0349.29
5.2.50.0120.0389.25
5.2.40.0140.0349.23
5.2.30.0240.0569.20
5.2.20.0160.0369.20
5.2.10.0160.0329.09
5.2.00.0140.0338.96
5.1.60.0150.0268.25
5.1.50.0110.0338.24
5.1.40.0100.0318.24
5.1.30.0180.0268.59
5.1.20.0120.0318.60
5.1.10.0110.0328.17
5.1.00.0110.0328.17
5.0.50.0120.0236.66
5.0.40.0140.0196.51
5.0.30.0100.0356.32
5.0.20.0090.0246.30
5.0.10.0110.0226.27
5.0.00.0050.0406.27
4.4.90.0080.0194.78
4.4.80.0060.0194.76
4.4.70.0220.0664.75
4.4.60.0080.0184.75
4.4.50.0060.0204.77
4.4.40.0100.0284.71
4.4.30.0080.0184.75
4.4.20.0070.0194.84
4.4.10.0060.0204.84
4.4.00.0050.0334.75
4.3.110.0080.0174.67
4.3.100.0080.0164.67
4.3.90.0040.0194.63
4.3.80.0040.0304.59
4.3.70.0050.0184.63
4.3.60.0060.0184.63
4.3.50.0070.0174.63
4.3.40.0090.0254.54
4.3.30.0060.0173.30
4.3.20.0080.0153.28
4.3.10.0040.0183.24
4.3.00.0200.01313.64

preferences:
39.92 ms | 401 KiB | 5 Q