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); }*/ return (array) $this->xml->$offset;//new self($this->xml->$offset->asXML(), false); } public function __toString() { die; 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); var_dump($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.0090.00618.55
8.3.50.0160.01021.94
8.3.40.0070.01118.91
8.3.30.0040.01119.36
8.3.20.0070.00020.60
8.3.10.0080.00322.25
8.3.00.0040.00422.55
8.2.180.0030.01717.00
8.2.170.0120.00322.96
8.2.160.0110.00421.14
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0060.00319.73
8.2.110.0070.00322.29
8.2.100.0000.01118.09
8.2.90.0050.00319.48
8.2.80.0040.00418.18
8.2.70.0040.00417.88
8.2.60.0090.00018.05
8.2.50.0040.00418.07
8.2.40.0050.00318.41
8.2.30.0030.00618.22
8.2.20.0050.00318.02
8.2.10.0040.00418.01
8.2.00.0040.00417.98
8.1.280.0040.01225.92
8.1.270.0080.00022.52
8.1.260.0080.00026.35
8.1.250.0150.00028.09
8.1.240.0030.00724.09
8.1.230.0110.00019.34
8.1.220.0080.00018.04
8.1.210.0000.00818.77
8.1.200.0040.00417.48
8.1.190.0040.00417.66
8.1.180.0040.00418.10
8.1.170.0060.00318.77
8.1.160.0030.00522.32
8.1.150.0000.00718.93
8.1.140.0080.00017.70
8.1.130.0000.00718.12
8.1.120.0000.00717.62
8.1.110.0050.00217.72
8.1.100.0060.00317.58
8.1.90.0000.00717.57
8.1.80.0060.00317.72
8.1.70.0000.00717.59
8.1.60.0030.00617.79
8.1.50.0040.00417.71
8.1.40.0060.00317.77
8.1.30.0030.00517.77
8.1.20.0000.00817.78
8.1.10.0000.00817.72
8.1.00.0000.00817.70
8.0.300.0000.00718.77
8.0.290.0090.00017.41
8.0.280.0030.00318.75
8.0.270.0050.00217.49
8.0.260.0040.00416.95
8.0.250.0000.00717.21
8.0.240.0000.00817.16
8.0.230.0030.00317.12
8.0.220.0000.00716.99
8.0.210.0000.00817.04
8.0.200.0030.00317.23
8.0.190.0040.00417.14
8.0.180.0070.00017.05
8.0.170.0040.00417.19
8.0.160.0040.00417.14
8.0.150.0040.00417.02
8.0.140.0000.00717.08
8.0.130.0000.00613.59
8.0.120.0040.00417.14
8.0.110.0050.00217.04
8.0.100.0000.00817.15
8.0.90.0040.00416.96
8.0.80.0090.00617.18
8.0.70.0040.00416.99
8.0.60.0040.00417.09
8.0.50.0080.00017.12
8.0.30.0170.00517.17
8.0.20.0090.01117.40
8.0.10.0040.00417.37
8.0.00.0140.00517.15
7.4.330.0000.00615.25
7.4.320.0000.00716.66
7.4.300.0000.00716.66
7.4.290.0000.00716.82
7.4.280.0000.00716.72
7.4.270.0030.00816.84
7.4.260.0070.00016.71
7.4.250.0000.00716.70
7.4.240.0040.00416.77
7.4.230.0040.00416.50
7.4.220.0110.00716.65
7.4.210.0040.01016.79
7.4.200.0070.00016.85
7.4.190.0040.00316.66
7.4.160.0110.00616.71
7.4.150.0100.01417.40
7.4.140.0110.01017.86
7.4.130.0050.01216.75
7.4.120.0120.00516.90
7.4.110.0060.01216.97
7.4.100.0130.00416.68
7.4.90.0040.01916.55
7.4.80.0110.00716.74
7.4.70.0070.01016.70
7.4.60.0030.01316.98
7.4.50.0000.00916.75
7.4.40.0090.00322.77
7.4.30.0060.01016.68
7.4.00.0100.00814.86
7.3.330.0060.00013.46
7.3.320.0050.00013.60
7.3.310.0070.00016.50
7.3.300.0020.00516.46
7.3.290.0060.00916.57
7.3.280.0110.00816.56
7.3.270.0130.01017.40
7.3.260.0130.00316.91
7.3.250.0050.01416.64
7.3.240.0060.01216.62
7.3.230.0140.00716.83
7.3.210.0070.01116.85
7.3.200.0070.01019.39
7.3.190.0030.01416.65
7.3.180.0090.00916.52
7.3.170.0110.01116.60
7.3.160.0030.01416.59
7.3.120.0080.01014.84
7.3.110.0110.00714.88
7.3.100.0090.00514.99
7.3.90.0080.00514.99
7.3.80.0050.01014.93
7.3.70.0090.00514.82
7.3.60.0050.01014.95
7.3.50.0060.00914.87
7.3.40.0070.00714.90
7.3.30.0040.01114.65
7.3.20.0090.00316.74
7.3.10.0050.00916.62
7.3.00.0050.01116.63
7.2.330.0060.01216.84
7.2.320.0100.01417.06
7.2.310.0090.00916.93
7.2.300.0100.00616.95
7.2.290.0120.00917.00
7.2.250.0070.01115.09
7.2.240.0070.01315.08
7.2.230.0070.00814.95
7.2.220.0110.00315.08
7.2.210.0050.01015.14
7.2.200.0080.00815.14
7.2.190.0040.01115.14
7.2.180.0080.00215.06
7.2.170.0050.00915.13
7.2.160.0030.01015.14
7.2.150.0140.00017.09
7.2.140.0070.00716.75
7.2.130.0080.00816.98
7.2.120.0050.01216.91
7.2.110.0030.01117.00
7.2.100.0050.00716.71
7.2.90.0030.01016.96
7.2.80.0050.00716.93
7.2.70.0010.01017.24
7.2.60.0070.00916.83
7.2.50.0090.00617.07
7.2.40.0070.00917.17
7.2.30.0100.00317.12
7.2.20.0030.01116.99
7.2.10.0050.00716.97
7.2.00.0050.00718.00
7.1.330.0070.00915.91
7.1.320.0010.00815.91
7.1.310.0030.01015.88
7.1.300.0100.00715.88
7.1.290.0070.00415.83
7.1.280.0070.00715.83
7.1.270.0080.00616.07
7.1.260.0050.01015.75
7.1.250.0060.00815.87
7.1.200.0030.01016.08
7.1.100.0090.00618.24
7.1.70.0000.01117.41
7.1.60.0110.01419.82
7.1.50.0070.01416.65
7.1.00.0000.08022.47
7.0.200.0070.00716.66
7.0.140.0030.07322.17
7.0.60.0030.06719.92
7.0.50.0030.06017.89
7.0.40.0100.05320.04
7.0.30.0300.08320.28
7.0.20.0300.05020.32
7.0.10.0230.05320.32
7.0.00.0070.06720.32
5.6.280.0100.06721.01
5.6.210.0070.03720.90
5.6.200.0130.04718.27
5.6.190.0100.03720.55
5.6.180.3970.04020.55
5.6.170.0470.06720.55
5.6.160.0100.04020.78
5.6.150.0000.04318.38
5.6.140.0030.04018.38
5.6.130.0000.04318.28
5.6.120.0000.06021.20
5.6.110.0130.08021.02
5.6.100.0100.07021.05
5.6.90.0100.07721.09
5.6.80.0130.03720.58
5.6.70.0030.09020.52
5.5.350.0000.08320.44
5.5.340.0070.06718.13
5.5.330.0070.04320.35
5.5.320.0270.04720.49
5.5.310.0200.05320.43
5.5.300.0070.08018.05
5.5.290.0130.07317.98
5.5.280.0070.04020.85
5.5.270.0070.06020.85
5.5.260.0070.07320.93
5.5.250.0130.07720.88
5.5.240.0100.08020.16
5.4.450.0300.04719.72
5.4.440.0600.04719.39
5.4.430.0000.03719.38
5.4.420.0330.04019.68
5.4.410.0170.04719.08
5.4.400.0230.05018.76
5.4.390.0100.05018.93
5.4.380.0200.05018.55
5.4.370.0200.05018.93
5.4.360.0200.04718.84
5.4.350.0170.05718.82
5.4.340.0200.04718.82
5.4.320.0070.03712.66
5.4.310.0040.04712.66
5.4.300.0060.04312.66
5.4.290.0030.03912.65
5.4.280.0050.03612.55
5.4.270.0030.04112.55
5.4.260.0030.04112.55
5.4.250.0090.04112.55
5.4.240.0100.04312.55
5.4.230.0060.04312.54
5.4.220.0060.03612.54
5.4.210.0080.03712.54
5.4.200.0070.04212.54
5.4.190.0180.04012.53
5.4.180.0150.04412.53
5.4.170.0160.04512.54
5.4.160.0240.09612.53
5.4.150.0160.04412.53
5.4.140.0170.04212.21
5.4.130.0150.04512.21
5.4.120.0190.03912.16
5.4.110.0140.04612.16
5.4.100.0170.04412.16
5.4.90.0260.03912.16
5.4.80.0220.04112.16
5.4.70.0310.09112.16
5.4.60.0150.04412.16
5.4.50.0180.04212.16
5.4.40.0520.07012.14
5.4.30.0130.04612.14
5.4.20.0160.04112.14
5.4.10.0200.03712.14
5.4.00.0150.04111.63
5.3.290.0070.04412.93
5.3.280.0050.03912.86
5.3.270.0380.08512.86
5.3.260.0160.04512.86
5.3.250.0120.04812.86
5.3.240.0210.03912.85
5.3.230.0130.04812.85
5.3.220.0180.04212.82
5.3.210.0170.04412.82
5.3.200.0260.06412.81
5.3.190.0190.04212.81
5.3.180.0170.04312.82
5.3.170.0130.04712.81
5.3.160.0180.04212.82
5.3.150.0160.04512.81
5.3.140.0200.04012.80
5.3.130.0280.06312.80
5.3.120.0200.04112.79
5.3.110.0190.04212.79
5.3.100.0270.06412.29
5.3.90.0190.04012.27
5.3.80.0200.04012.26
5.3.70.0160.04312.26
5.3.60.0120.04812.23
5.3.50.0260.06312.19
5.3.40.0180.04212.19
5.3.30.0190.04112.15
5.3.20.0150.04311.93
5.3.10.0200.06711.90
5.3.00.0150.04211.88
5.2.170.0150.0329.38
5.2.160.0110.0369.38
5.2.150.0100.0389.38
5.2.140.0110.0379.38
5.2.130.0070.0399.34
5.2.120.0100.0369.34
5.2.110.0110.0379.34
5.2.100.0100.0369.34
5.2.90.0130.0339.34
5.2.80.0130.0349.34
5.2.70.0110.0369.33
5.2.60.0140.0329.29
5.2.50.0130.0349.25
5.2.40.0150.0329.23
5.2.30.0100.0369.21
5.2.20.0220.0859.20
5.2.10.0140.0319.10
5.2.00.0140.0318.95
5.1.60.0140.0258.24
5.1.50.0090.0318.24
5.1.40.0110.0308.23
5.1.30.0130.0298.58
5.1.20.0140.0298.59
5.1.10.0130.0308.16
5.1.00.0100.0328.17
5.0.50.0110.0236.65
5.0.40.0090.0226.51
5.0.30.0090.0346.32
5.0.20.0090.0226.29
5.0.10.0080.0236.27
5.0.00.0070.0366.26
4.4.90.0070.0174.78
4.4.80.0060.0184.76
4.4.70.0070.0194.75
4.4.60.0050.0204.75
4.4.50.0090.0164.77
4.4.40.0080.0274.71
4.4.30.0070.0184.76
4.4.20.0070.0184.84
4.4.10.0060.0194.85
4.4.00.0050.0314.76
4.3.110.0060.0184.67
4.3.100.0320.0554.67
4.3.90.0090.0154.64
4.3.80.0060.0294.58
4.3.70.0040.0204.63
4.3.60.0040.0204.63
4.3.50.0050.0194.62
4.3.40.0080.0254.54
4.3.30.0060.0183.30
4.3.20.0020.0213.28
4.3.10.0050.0183.24
4.3.00.0100.01313.29

preferences:
39.16 ms | 401 KiB | 5 Q