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; } var_dump((array) $this->xml->$offset); 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'][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.0120.00918.65
8.3.50.0110.01022.10
8.3.40.0150.00419.13
8.3.30.0180.00019.17
8.3.20.0050.00320.55
8.3.10.0050.00323.78
8.3.00.0030.00622.52
8.2.180.0080.00817.13
8.2.170.0110.00422.96
8.2.160.0100.00322.34
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00419.48
8.2.110.0040.00422.40
8.2.100.0040.00818.16
8.2.90.0000.00819.47
8.2.80.0050.00318.15
8.2.70.0000.00917.75
8.2.60.0000.00818.05
8.2.50.0070.00418.07
8.2.40.0050.00318.47
8.2.30.0000.00718.37
8.2.20.0000.00817.86
8.2.10.0040.00419.74
8.2.00.0090.00017.92
8.1.280.0130.00625.92
8.1.270.0080.00023.96
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0050.00524.04
8.1.230.0090.00319.20
8.1.220.0040.00418.04
8.1.210.0090.00318.77
8.1.200.0030.00717.60
8.1.190.0000.00917.80
8.1.180.0030.00518.10
8.1.170.0030.00618.84
8.1.160.0040.00422.19
8.1.150.0030.00618.82
8.1.140.0030.00517.70
8.1.130.0030.00517.95
8.1.120.0040.00417.80
8.1.110.0040.00417.70
8.1.100.0000.00717.71
8.1.90.0070.00017.72
8.1.80.0030.00317.66
8.1.70.0030.00317.60
8.1.60.0080.00417.86
8.1.50.0040.00417.71
8.1.40.0030.00517.77
8.1.30.0040.00417.80
8.1.20.0000.00817.79
8.1.10.0030.00617.76
8.1.00.0040.00417.73
8.0.300.0040.00418.77
8.0.290.0000.00717.29
8.0.280.0040.00418.71
8.0.270.0040.00417.37
8.0.260.0100.00017.10
8.0.250.0030.00317.07
8.0.240.0000.00717.20
8.0.230.0030.00317.09
8.0.220.0000.00817.07
8.0.210.0040.00417.14
8.0.200.0030.00317.17
8.0.190.0000.00717.09
8.0.180.0000.00917.02
8.0.170.0000.00817.05
8.0.160.0000.00717.06
8.0.150.0040.00416.92
8.0.140.0040.00416.98
8.0.130.0030.00313.51
8.0.120.0060.00317.12
8.0.110.0040.00417.19
8.0.100.0040.00417.06
8.0.90.0050.00317.14
8.0.80.0090.00716.98
8.0.70.0070.00017.15
8.0.60.0000.00817.06
8.0.50.0000.00716.98
8.0.30.0170.00717.36
8.0.20.0140.00517.40
8.0.10.0020.00517.30
8.0.00.0140.01017.07
7.4.330.0030.00315.33
7.4.320.0000.00616.68
7.4.300.0000.00716.83
7.4.290.0000.00716.74
7.4.280.0030.00316.77
7.4.270.0000.00916.71
7.4.260.0030.00316.89
7.4.250.0040.00316.80
7.4.240.0010.00716.78
7.4.230.0000.00716.94
7.4.220.0090.00916.75
7.4.210.0090.00916.74
7.4.200.0050.00316.81
7.4.190.0040.00417.00
7.4.160.0070.01016.70
7.4.150.0140.00317.40
7.4.140.0090.01117.86
7.4.130.0130.00816.73
7.4.120.0100.00816.79
7.4.110.0130.01016.75
7.4.100.0070.01116.77
7.4.90.0100.01316.62
7.4.80.0110.01116.69
7.4.70.0170.00016.83
7.4.60.0030.01316.78
7.4.50.0030.00616.58
7.4.40.0000.01822.77
7.4.30.0140.01016.59
7.4.00.0070.01015.18
7.3.330.0030.00313.40
7.3.320.0000.00713.30
7.3.310.0030.00516.62
7.3.300.0000.00716.63
7.3.290.0090.00916.59
7.3.280.0130.00616.55
7.3.270.0090.00817.40
7.3.260.0130.01016.80
7.3.250.0130.00816.76
7.3.240.0090.01316.77
7.3.230.0160.00016.60
7.3.210.0060.01616.82
7.3.200.0090.00919.39
7.3.190.0100.01416.61
7.3.180.0100.01116.79
7.3.170.0140.00316.77
7.3.160.0080.00816.53
7.3.120.0030.00915.00
7.2.330.0050.01417.02
7.2.320.0060.01216.92
7.2.310.0140.00917.02
7.2.300.0050.01317.07
7.2.290.0110.00617.06
7.1.100.0060.00618.11
7.1.70.0030.01317.36
7.1.60.0090.00919.24
7.1.50.0120.00917.00
7.1.00.0030.07722.57
7.0.200.0130.00016.60
7.0.140.0170.06022.04
7.0.60.0030.04020.04
7.0.50.0000.08018.10
7.0.40.0030.05720.41
7.0.30.0170.04320.37
7.0.20.0300.07320.30
7.0.10.0270.08020.25
7.0.00.0100.08720.31
5.6.280.0030.07321.04
5.6.210.0130.07320.58
5.6.200.0100.05318.31
5.6.190.0130.08320.57
5.6.180.3070.03320.74
5.6.170.0430.07320.60
5.6.160.0130.08320.64
5.6.150.0000.05718.36
5.6.140.0030.06718.30
5.6.130.0130.06718.36
5.6.120.0100.08021.14
5.6.110.0070.08721.23
5.6.100.0070.04021.04
5.6.90.0070.08321.12
5.6.80.0170.02720.45
5.6.70.2270.03720.60
5.5.350.0030.06720.47
5.5.340.0070.07718.12
5.5.330.0070.08020.41
5.5.320.0430.04320.36
5.5.310.0270.08320.37
5.5.300.0130.08018.02
5.5.290.0030.07018.17
5.5.280.0030.04720.86
5.5.270.0000.04720.93
5.5.260.0100.03320.89
5.5.250.0100.04020.68
5.5.240.0070.07320.24
5.4.450.0330.04319.72
5.4.440.0800.05019.72
5.4.430.0630.04319.48
5.4.420.0300.05719.64
5.4.410.0030.06018.95
5.4.400.0070.05718.88
5.4.390.0130.05018.84
5.4.380.0170.05318.77
5.4.370.0170.05018.58
5.4.360.0270.03718.82
5.4.350.0100.05718.85
5.4.340.0130.05018.84
5.4.320.0090.04112.66
5.4.310.0070.04312.66
5.4.300.0080.04012.66
5.4.290.0040.03912.66
5.4.280.0080.04112.55
5.4.270.0030.04112.56
5.4.260.0030.04112.56
5.4.250.0050.03912.55
5.4.240.0030.04012.55
5.4.230.0050.04312.55
5.4.220.0080.04412.55
5.4.210.0080.04312.54
5.4.200.0080.03812.54
5.4.190.0140.04612.54
5.4.180.0160.04412.54
5.4.170.0150.04512.55
5.4.160.0170.04612.54
5.4.150.0170.04912.54
5.4.140.0330.08912.22
5.4.130.0200.03912.21
5.4.120.0120.04612.17
5.4.110.0170.04012.16
5.4.100.0160.04212.16
5.4.90.0180.04012.16
5.4.80.0170.04012.16
5.4.70.0180.03912.16
5.4.60.0120.04612.16
5.4.50.0180.04312.16
5.4.40.0210.03812.16
5.4.30.0320.08712.15
5.4.20.0140.04312.15
5.4.10.0180.04112.15
5.4.00.0320.08711.63
5.3.290.0110.04412.93
5.3.280.0070.04212.86
5.3.270.0170.04512.85
5.3.260.0170.04512.85
5.3.250.0170.04512.85
5.3.240.0160.04612.85
5.3.230.0110.05112.84
5.3.220.0150.04712.81
5.3.210.0200.04512.81
5.3.200.0200.04512.80
5.3.190.0200.04812.81
5.3.180.0210.04012.81
5.3.170.0210.04012.81
5.3.160.0140.04612.81
5.3.150.0240.03912.81
5.3.140.0150.04612.80
5.3.130.0190.04412.80
5.3.120.0210.03912.79
5.3.110.0210.04112.79
5.3.100.0180.04212.28
5.3.90.0200.04012.26
5.3.80.0300.09512.25
5.3.70.0190.04212.26
5.3.60.0220.04012.23
5.3.50.0160.04712.19
5.3.40.0140.04912.19
5.3.30.0150.04312.15
5.3.20.0200.03911.92
5.3.10.0140.04311.89
5.3.00.0140.04311.88
5.2.170.0150.0349.39
5.2.160.0350.0739.38
5.2.150.0170.0319.38
5.2.140.0150.0339.38
5.2.130.0090.0379.34
5.2.120.0130.0349.34
5.2.110.0120.0389.35
5.2.100.0130.0359.34
5.2.90.0180.0289.35
5.2.80.0170.0319.34
5.2.70.0090.0409.34
5.2.60.0180.0329.29
5.2.50.0360.0719.26
5.2.40.0130.0349.23
5.2.30.0120.0349.21
5.2.20.0160.0339.20
5.2.10.0180.0319.11
5.2.00.0150.0348.95
5.1.60.0120.0298.25
5.1.50.0080.0348.25
5.1.40.0120.0318.24
5.1.30.0100.0338.59
5.1.20.0140.0298.60
5.1.10.0210.0578.17
5.1.00.0120.0308.17
5.0.50.0090.0266.66
5.0.40.0130.0196.51
5.0.30.0150.0296.33
5.0.20.0100.0256.30
5.0.10.0030.0296.27
5.0.00.0150.0346.27
4.4.90.0100.0184.78
4.4.80.0030.0224.75
4.4.70.0080.0184.75
4.4.60.0100.0164.75
4.4.50.0100.0154.77
4.4.40.0060.0304.71
4.4.30.0120.0144.76
4.4.20.0060.0204.84
4.4.10.0330.0554.84
4.4.00.0090.0334.76
4.3.110.0090.0174.67
4.3.100.0070.0204.66
4.3.90.0070.0184.63
4.3.80.0060.0294.58
4.3.70.0060.0194.63
4.3.60.0080.0174.63
4.3.50.0100.0184.63
4.3.40.0090.0274.54
4.3.30.0050.0233.30
4.3.20.0060.0193.27
4.3.10.0090.0163.24
4.3.00.0100.01713.28

preferences:
38.38 ms | 400 KiB | 5 Q