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)) { var_dump($this->xml); return new self($this->xml[$offset]->asXML(), false); } var_dump((array)$this->xml); 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']['0'];

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.0150.00416.88
8.3.50.0130.00622.02
8.3.40.0070.00719.21
8.3.30.0110.00419.17
8.3.20.0080.00020.60
8.3.10.0080.00023.78
8.3.00.0110.00019.75
8.2.180.0070.00718.52
8.2.170.0060.00922.96
8.2.160.0120.00320.77
8.2.150.0050.00524.18
8.2.140.0000.00824.66
8.2.130.0120.00626.16
8.2.120.0040.00422.49
8.2.110.0090.00022.51
8.2.100.0090.00318.28
8.2.90.0040.00419.65
8.2.80.0050.00318.05
8.2.70.0040.00417.75
8.2.60.0000.00818.29
8.2.50.0040.00418.07
8.2.40.0050.00318.28
8.2.30.0080.00018.49
8.2.20.0000.00818.14
8.2.10.0080.00018.43
8.2.00.0090.00017.95
8.1.280.0110.00725.92
8.1.270.0090.00024.16
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.95
8.1.230.0090.00319.32
8.1.220.0000.00918.04
8.1.210.0060.00318.77
8.1.200.0090.00317.61
8.1.190.0090.00017.89
8.1.180.0000.00818.10
8.1.170.0050.00518.80
8.1.160.0040.00422.37
8.1.150.0080.00018.83
8.1.140.0080.00017.62
8.1.130.0000.00718.13
8.1.120.0040.00417.76
8.1.110.0040.00417.76
8.1.100.0070.00017.71
8.1.90.0000.00717.81
8.1.80.0030.00517.77
8.1.70.0040.00417.61
8.1.60.0030.00617.84
8.1.50.0000.00917.72
8.1.40.0030.00517.71
8.1.30.0040.00417.85
8.1.20.0040.00417.94
8.1.10.0040.00417.77
8.1.00.0030.00517.80
8.0.300.0070.00018.77
8.0.290.0070.00017.30
8.0.280.0050.00218.73
8.0.270.0040.00417.41
8.0.260.0000.00717.46
8.0.250.0070.00017.30
8.0.240.0050.00217.19
8.0.230.0000.00717.36
8.0.220.0000.00717.21
8.0.210.0000.00717.19
8.0.200.0070.00017.24
8.0.190.0000.00817.21
8.0.180.0020.00517.31
8.0.170.0000.00817.25
8.0.160.0070.00017.20
8.0.150.0080.00317.29
8.0.140.0000.00817.15
8.0.130.0000.00613.67
8.0.120.0080.00017.23
8.0.110.0000.00717.27
8.0.100.0030.00517.26
8.0.90.0000.00716.98
8.0.80.0030.01317.17
8.0.70.0030.00617.14
8.0.60.0040.00416.98
8.0.50.0040.00416.97
8.0.30.0100.01017.32
8.0.20.0070.01217.40
8.0.10.0000.00717.42
8.0.00.0090.01016.84
7.4.330.0030.00315.35
7.4.320.0040.00416.91
7.4.300.0030.00316.75
7.4.290.0040.00416.85
7.4.280.0000.00816.89
7.4.270.0040.00416.81
7.4.260.0000.00716.69
7.4.250.0040.00416.80
7.4.240.0050.00216.86
7.4.230.0070.00016.96
7.4.220.0060.01216.76
7.4.210.0040.01116.84
7.4.200.0040.00416.98
7.4.190.0000.00716.98
7.4.160.0200.01716.94
7.4.150.0060.01217.40
7.4.140.0100.00817.86
7.4.130.0220.00716.84
7.4.120.0110.00716.76
7.4.110.0110.00716.73
7.4.100.0110.01116.82
7.4.90.0100.01016.86
7.4.80.0060.01219.39
7.4.70.0140.00316.87
7.4.60.0060.01416.73
7.4.50.0000.00816.93
7.4.40.0000.01122.77
7.4.30.0070.01016.52
7.4.00.0070.00714.77
7.3.330.0000.00513.52
7.3.320.0050.00013.57
7.3.310.0000.00716.79
7.3.300.0030.00316.73
7.3.290.0120.00916.70
7.3.280.0140.00516.72
7.3.270.0150.01017.40
7.3.260.0280.02516.65
7.3.250.0090.01316.80
7.3.240.0120.00916.95
7.3.230.0090.00916.68
7.3.210.0150.00316.73
7.3.200.0170.00319.39
7.3.190.0050.01416.95
7.3.180.0030.01316.76
7.3.170.0080.01216.74
7.3.160.0090.00916.73
7.3.120.0120.00314.99
7.2.330.0100.00716.74
7.2.320.0090.01517.08
7.2.310.0140.00316.92
7.2.300.0070.01016.85
7.2.290.0130.00817.02
7.2.00.0000.01219.19
7.1.100.0030.01018.23
7.1.70.0000.01017.34
7.1.60.0160.01019.33
7.1.50.0090.02034.89
7.1.00.0030.07722.58
7.0.200.0000.00816.61
7.0.140.0070.06722.19
7.0.60.0070.05020.20
7.0.50.0070.07317.97
7.0.40.0130.08320.20
7.0.30.0230.08020.35
7.0.20.0300.07320.32
7.0.10.0030.06020.42
7.0.00.0070.06020.30
5.6.280.0070.07321.16
5.6.210.0100.07020.71
5.6.200.0070.08318.43
5.6.190.0030.05020.75
5.6.180.0000.08720.79
5.6.170.0330.07320.63
5.6.160.0200.06720.61
5.6.150.0170.06718.37
5.6.140.0070.06318.20
5.6.130.0100.08318.41
5.6.120.0130.06021.09
5.6.110.0070.08321.19
5.6.100.0170.05721.17
5.6.90.0030.04021.04
5.6.80.0100.06020.57
5.5.350.0130.06720.54
5.5.340.0000.04318.12
5.5.330.0030.05020.23
5.5.320.0430.06720.40
5.5.310.0230.05320.51
5.5.300.0070.07018.11
5.5.290.0100.04318.20
5.5.280.0170.06720.80
5.5.270.0070.09020.84
5.5.260.0000.09020.83
5.5.250.0100.08020.66
5.5.240.2770.03320.27
5.4.450.0270.05019.77
5.4.440.1000.04719.59
5.4.430.0770.04319.42
5.4.420.1000.07319.52
5.4.410.0770.05319.53
5.4.400.0730.06319.31
5.4.390.0830.05019.16
5.4.380.0130.05718.69
5.4.370.0370.05018.79
5.4.360.0230.06318.95
5.4.350.0300.07318.95
5.4.340.0130.05318.92
5.4.320.0090.03312.71
5.4.310.0090.04212.70
5.4.300.0050.03812.70
5.4.290.0040.04512.70
5.4.280.0050.04012.59
5.4.270.0040.04212.59
5.4.260.0050.04412.59
5.4.250.0040.04312.60
5.4.240.0050.03612.59
5.4.230.0060.04212.59
5.4.220.0060.04412.59
5.4.210.0030.04012.58
5.4.200.0050.03912.59
5.4.190.0190.04212.57
5.4.180.0360.08612.57
5.4.170.0130.04712.59
5.4.160.0150.04612.59
5.4.150.0150.04512.58
5.4.140.0170.04212.26
5.4.130.0150.04512.25
5.4.120.0160.04212.21
5.4.110.0190.03912.20
5.4.100.0200.04112.20
5.4.90.0210.03912.20
5.4.80.0210.07112.21
5.4.70.0180.04012.20
5.4.60.0150.04512.20
5.4.50.0310.06012.20
5.4.40.0210.03912.19
5.4.30.0160.04512.18
5.4.20.0280.09012.19
5.4.10.0130.04612.18
5.4.00.0150.04311.67
5.3.290.0120.04012.97
5.3.280.0090.03512.90
5.3.270.0180.04512.89
5.3.260.0180.04512.89
5.3.250.0270.06812.90
5.3.240.0170.04512.89
5.3.230.0250.07012.89
5.3.220.0240.03912.86
5.3.210.0190.04812.87
5.3.200.0200.04712.85
5.3.190.0300.07112.86
5.3.180.0210.04812.85
5.3.170.0330.09012.85
5.3.160.0270.04712.86
5.3.150.0200.04412.86
5.3.140.0200.04612.85
5.3.130.0200.04712.84
5.3.120.0200.04812.84
5.3.110.0210.04612.84
5.3.100.0350.08912.32
5.3.90.0130.04612.30
5.3.80.0200.04212.30
5.3.70.0220.03912.30
5.3.60.0190.04512.27
5.3.50.0220.04312.23
5.3.40.0370.08712.23
5.3.30.0190.04512.20
5.3.20.0140.04611.97
5.3.10.0260.06511.93
5.3.00.0180.04411.92
5.2.170.0090.0409.43
5.2.160.0190.0329.44
5.2.150.0270.0559.44
5.2.140.0150.0379.43
5.2.130.0140.0349.39
5.2.120.0160.0319.39
5.2.110.0330.0809.40
5.2.100.0140.0369.39
5.2.90.0100.0399.39
5.2.80.0140.0349.38
5.2.70.0170.0369.38
5.2.60.0280.0549.34
5.2.50.0130.0389.31
5.2.40.0130.0359.29
5.2.30.0150.0389.26
5.2.20.0120.0369.25
5.2.10.0120.0359.15
5.2.00.0150.0369.01
5.1.60.0090.0318.30
5.1.50.0100.0328.30
5.1.40.0130.0308.28
5.1.30.0130.0318.63
5.1.20.0190.0558.60
5.1.10.0140.0318.17
5.1.00.0090.0338.17
5.0.50.0130.0226.65
5.0.40.0390.0286.50
5.0.30.0320.0766.32
5.0.20.0100.0236.29
5.0.10.0130.0206.27
5.0.00.0070.0376.26
4.4.90.0100.0154.78
4.4.80.0090.0164.76
4.4.70.0050.0204.75
4.4.60.0080.0194.76
4.4.50.0060.0194.77
4.4.40.0070.0314.71
4.4.30.0130.0144.76
4.4.20.0110.0164.84
4.4.10.0080.0184.85
4.4.00.0100.0274.76
4.3.110.0090.0164.67
4.3.100.0060.0194.66
4.3.90.0080.0174.63
4.3.80.0050.0314.58
4.3.70.0060.0204.63
4.3.60.0070.0174.63
4.3.50.0080.0164.63
4.3.40.0070.0284.54
4.3.30.0030.0213.30
4.3.20.0050.0183.27
4.3.10.0060.0173.24
4.3.00.0030.0237.80

preferences:
39.05 ms | 401 KiB | 5 Q