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) ((array) $this->xml->$offset)[0]; } 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.0160.00318.68
8.3.50.0170.00522.17
8.3.40.0120.00318.96
8.3.30.0060.00919.21
8.3.20.0080.00019.01
8.3.10.0040.00421.43
8.3.00.0040.00422.03
8.2.180.0070.01016.75
8.2.170.0080.00822.96
8.2.160.0030.01020.46
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0070.00021.13
8.2.110.0060.00321.30
8.2.100.0040.00718.16
8.2.90.0040.00419.28
8.2.80.0040.00417.97
8.2.70.0030.00617.88
8.2.60.0050.00318.18
8.2.50.0060.00618.07
8.2.40.0000.00818.28
8.2.30.0070.00021.54
8.2.20.0060.00317.94
8.2.10.0040.00418.05
8.2.00.0000.00917.90
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0090.00022.44
8.1.230.0070.00419.26
8.1.220.0060.00317.90
8.1.210.0060.00318.77
8.1.200.0040.00417.48
8.1.190.0040.00419.38
8.1.180.0030.00518.10
8.1.170.0000.00818.89
8.1.160.0040.00419.07
8.1.150.0050.00318.87
8.1.140.0050.00317.72
8.1.130.0000.00718.00
8.1.120.0050.00217.70
8.1.110.0040.00417.62
8.1.100.0070.00017.71
8.1.90.0040.00417.62
8.1.80.0040.00417.67
8.1.70.0000.00717.65
8.1.60.0080.00017.84
8.1.50.0000.00917.69
8.1.40.0030.00517.64
8.1.30.0000.00817.93
8.1.20.0000.00817.72
8.1.10.0060.00317.71
8.1.00.0000.00817.83
8.0.300.0050.00318.77
8.0.290.0030.00616.75
8.0.280.0070.00018.60
8.0.270.0000.00717.50
8.0.260.0000.00717.09
8.0.250.0050.00317.30
8.0.240.0030.00617.28
8.0.230.0000.00717.15
8.0.220.0000.00717.21
8.0.210.0000.00717.09
8.0.200.0070.00017.13
8.0.190.0030.00517.24
8.0.180.0060.00317.07
8.0.170.0040.00417.11
8.0.160.0000.00717.18
8.0.150.0020.00517.06
8.0.140.0050.00317.12
8.0.130.0030.00613.62
8.0.120.0030.00517.14
8.0.110.0050.00317.30
8.0.100.0030.00516.98
8.0.90.0000.00717.30
8.0.80.0030.01317.11
8.0.70.0000.00717.06
8.0.60.0040.00417.05
8.0.50.0000.00717.05
8.0.30.0080.01217.45
8.0.20.0130.00617.61
8.0.10.0070.00017.17
8.0.00.0050.01216.93
7.4.330.0050.00015.04
7.4.320.0000.00616.65
7.4.300.0060.00016.59
7.4.290.0070.00016.74
7.4.280.0060.00316.73
7.4.270.0030.00316.72
7.4.260.0030.00313.41
7.4.250.0030.00616.71
7.4.240.0040.00416.85
7.4.230.0070.00016.68
7.4.220.0090.01016.71
7.4.210.0110.00716.76
7.4.200.0040.00416.67
7.4.190.0080.00016.83
7.4.160.0080.01216.98
7.4.150.0000.01817.40
7.4.140.0100.00717.86
7.4.130.0140.00516.78
7.4.120.0060.01416.77
7.4.110.0100.00716.78
7.4.100.0110.00816.67
7.4.90.0120.01216.68
7.4.80.0020.00719.39
7.4.70.0080.00816.60
7.4.60.0100.00916.76
7.4.50.0000.00916.57
7.4.40.0090.00522.77
7.4.30.0100.00716.75
7.4.00.0070.00715.09
7.3.330.0030.00313.60
7.3.320.0000.00613.43
7.3.310.0000.00716.70
7.3.300.0000.00716.63
7.3.290.0140.00016.70
7.3.280.0060.01016.61
7.3.270.0130.00417.40
7.3.260.0080.01018.24
7.3.250.0100.00916.77
7.3.240.0070.01116.70
7.3.230.0100.00816.76
7.3.210.0090.00916.57
7.3.200.0070.01619.39
7.3.190.0150.00916.78
7.3.180.0040.01216.76
7.3.170.0130.00716.70
7.3.160.0130.00816.84
7.3.120.0070.01015.11
7.3.110.0040.01515.33
7.3.100.0040.01214.85
7.3.90.0070.00714.83
7.3.80.0060.01015.14
7.3.70.0120.00415.03
7.3.60.0090.00315.05
7.3.50.0000.01315.14
7.3.40.0090.00314.80
7.3.30.0070.00714.97
7.3.20.0140.00016.99
7.3.10.0060.00616.66
7.3.00.0080.00416.72
7.2.330.0090.00916.75
7.2.320.0090.00917.01
7.2.310.0130.00317.00
7.2.300.0100.01316.82
7.2.290.0160.00616.65
7.2.250.0070.01315.24
7.2.240.0130.00714.93
7.2.230.0120.00315.17
7.2.220.0130.00315.34
7.2.210.0090.00615.25
7.2.200.0090.00615.23
7.2.190.0070.00715.13
7.2.180.0110.00415.35
7.2.170.0030.01015.32
7.2.60.0080.00017.09
7.2.00.0060.00619.56
7.1.330.0090.00615.77
7.1.320.0150.00315.88
7.1.310.0060.00615.97
7.1.300.0000.01616.02
7.1.290.0040.01115.56
7.1.280.0030.00615.64
7.1.270.0070.00715.84
7.1.260.0030.01215.93
7.1.200.0060.00616.14
7.1.100.0040.00718.35
7.1.70.0070.00717.41
7.1.60.0030.02019.40
7.1.50.0030.02216.99
7.1.00.0000.04322.52
7.0.200.0050.00816.74
7.0.140.0000.07722.16
7.0.70.0170.07021.77
7.0.60.0130.05021.93
7.0.50.0070.05322.23
7.0.40.0070.07720.18
7.0.30.0100.08720.27
7.0.20.0030.09020.05
7.0.10.0100.08320.13
7.0.00.0070.08720.27
5.6.280.0070.07020.90
5.6.220.0000.08720.61
5.6.210.0030.08720.57
5.6.200.0030.08321.07
5.6.190.0170.07721.12
5.6.180.0100.06721.11
5.6.170.0100.08321.13
5.6.160.0130.07021.09
5.6.150.0130.04721.07
5.6.140.0000.08721.18
5.6.130.0030.09021.10
5.6.120.0070.08721.05
5.6.110.0030.08321.02
5.6.100.0030.08320.93
5.6.90.0070.08021.01
5.6.80.0100.05020.28
5.6.70.0130.04320.32
5.6.60.0070.07720.44
5.6.50.0030.04720.50
5.6.40.0030.07020.40
5.6.30.0000.09020.50
5.6.20.0170.07320.43
5.6.10.0130.05020.40
5.6.00.0030.06720.44
5.5.360.0070.08020.45
5.5.350.0030.08320.41
5.5.340.0030.08720.77
5.5.330.0070.08720.81
5.5.320.0030.07320.80
5.5.310.0100.06320.88
5.5.300.0070.08320.92
5.5.290.0070.10020.89
5.5.280.0070.08320.89
5.5.270.0030.08320.78
5.5.260.0130.07720.80
5.5.250.0030.08720.45
5.5.240.0100.04020.13
5.5.230.0100.06720.16
5.5.220.0030.08020.15
5.5.210.0030.08320.17
5.5.200.0030.07320.01
5.5.190.0070.08320.23
5.5.180.0070.08320.25
5.5.160.0070.07320.28
5.5.150.0030.08720.23
5.5.140.0000.06720.28
5.5.130.0100.07020.27
5.5.120.0030.07720.23
5.5.110.0030.06720.07
5.5.100.0030.04720.18
5.5.90.0130.07720.12
5.5.80.0070.07720.12
5.5.70.0100.08020.11
5.5.60.0000.05320.05
5.5.50.0030.08320.01
5.5.40.0130.06720.06
5.5.30.0100.07720.06
5.5.20.0070.08020.05
5.5.10.0100.06020.05
5.5.00.0070.08019.94
5.4.450.0130.07719.38
5.4.440.0070.07319.40
5.4.430.0170.05719.36
5.4.420.0000.05719.45
5.4.410.0070.07719.05
5.4.400.0100.07719.05
5.4.390.0070.06318.88
5.4.380.0200.06719.12
5.4.370.0030.05318.85
5.4.360.0070.04019.18
5.4.350.0030.08018.91
5.4.340.0030.05319.23
5.4.320.0030.08319.09
5.4.310.0070.07719.03
5.4.300.0070.05319.18
5.4.290.0030.07719.23
5.4.280.0100.07318.86
5.4.270.0170.06719.23
5.4.260.0070.07719.13
5.4.250.0100.07019.10
5.4.240.0000.05019.17
5.4.230.0070.08318.87
5.4.220.0070.04019.09
5.4.210.0000.06319.08
5.4.200.0030.08319.02
5.4.190.0100.07719.02
5.4.180.0070.07319.04
5.4.170.0070.05319.11
5.4.160.0100.07019.11
5.4.150.0030.08018.85
5.4.140.0000.06716.34
5.4.130.0100.07316.41
5.4.120.0030.07016.49
5.4.110.0100.07016.47
5.4.100.0030.06316.36
5.4.90.0000.06716.36
5.4.80.0030.07016.38
5.4.70.0130.07016.49
5.4.60.0030.07316.42
5.4.50.0070.07016.48
5.4.40.0030.05316.50
5.4.30.0070.07016.29
5.4.20.0070.07316.36
5.4.10.0030.07016.48
5.4.00.0070.07015.94
5.3.290.0030.08714.75
5.3.280.0030.07714.67
5.3.270.0030.04014.55
5.3.260.0100.07314.62
5.3.250.0100.05714.67
5.3.240.0070.07714.71
5.3.230.0070.05714.60
5.3.220.0030.05714.68
5.3.210.0170.07014.60
5.3.200.0100.07714.51
5.3.190.0030.07314.50
5.3.180.0030.06014.71
5.3.170.0100.07014.51
5.3.160.0030.08014.61
5.3.150.0070.08014.59
5.3.140.0100.07314.52
5.3.130.0070.06714.62
5.3.120.0030.07314.58
5.3.110.0030.08314.70
5.3.100.0030.08014.19
5.3.90.0070.06713.97
5.3.80.0030.06313.95
5.3.70.0030.08714.08
5.3.60.0100.07014.14
5.3.50.0030.05714.05
5.3.40.0100.04313.85
5.3.30.0000.08313.86
5.3.20.0000.07713.70
5.3.10.0100.07313.65
5.3.00.0030.07713.74
5.2.170.0000.07012.41
5.2.160.0100.04712.41
5.2.150.0070.06012.41
5.2.140.0000.06012.41
5.2.130.0130.05712.41
5.2.120.0030.04712.41
5.2.110.0030.06712.41
5.2.100.0030.04312.41
5.2.90.0000.03012.41
5.2.80.0070.03712.41
5.2.70.0030.06012.41
5.2.60.0100.04312.41
5.2.50.0000.05312.41
5.2.40.0000.05712.41
5.2.30.0070.06012.41
5.2.20.0030.05312.41
5.2.10.0000.04712.41
5.2.00.0000.04312.41
5.1.60.0070.04312.41
5.1.50.0100.05712.41
5.1.40.0000.06012.41
5.1.30.0030.05012.41
5.1.20.0030.05012.41
5.1.10.0000.05712.41
5.1.00.0000.04312.41
5.0.50.0030.02012.41
5.0.40.0030.04312.41
5.0.30.0030.05312.41
5.0.20.0000.04712.41
5.0.10.0030.03712.41
5.0.00.0000.07012.41
4.4.90.0000.02712.41
4.4.80.0030.03312.41
4.4.70.0000.03312.41
4.4.60.0070.03312.41
4.4.50.0030.03312.41
4.4.40.0000.05012.41
4.4.30.0000.04012.41
4.4.20.0000.02312.41
4.4.10.0000.03312.41
4.4.00.0000.02312.41
4.3.110.0000.03712.41
4.3.100.0000.03312.41
4.3.90.0000.03712.41
4.3.80.0000.03712.41
4.3.70.0000.03012.41
4.3.60.0000.02312.41
4.3.50.0000.02012.41
4.3.40.0000.03012.41
4.3.30.0000.03712.41
4.3.20.0000.02312.41
4.3.10.0030.03712.41
4.3.00.0000.03712.41

preferences:
36.37 ms | 401 KiB | 5 Q