3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlArrayAccessIterator implements ArrayAccess, IteratorAggregate { private $xml; private $iterator; public function __construct($filePath, $isUrl = true) { $this->isUrl = $isUrl; $this->iterator = $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; } return $this->iterator = new ArrayIterator((array)$this->xml->$offset); } public function __toString() { var_dump($this->iterator[0]); return (string) $this->iterator[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'][0]; var_dump($xml->getIterator());

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.70.0040.01517.00
8.3.60.0110.00718.78
8.3.50.0090.00922.10
8.3.40.0070.00719.21
8.3.30.0100.00719.28
8.3.20.0080.00020.58
8.3.10.0040.00423.78
8.3.00.0140.00020.88
8.2.190.0070.00717.13
8.2.180.0130.00617.25
8.2.170.0040.01222.96
8.2.160.0140.00022.27
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0000.00826.16
8.2.120.0050.00322.37
8.2.110.0000.00922.26
8.2.100.0060.01017.98
8.2.90.0030.00619.42
8.2.80.0060.00318.00
8.2.70.0080.00017.88
8.2.60.0060.00318.05
8.2.50.0060.00318.07
8.2.40.0040.00419.46
8.2.30.0070.00018.33
8.2.20.0080.00018.04
8.2.10.0050.00318.14
8.2.00.0000.00918.10
8.1.280.0120.00625.92
8.1.270.0090.00624.21
8.1.260.0030.00526.35
8.1.250.0100.01028.09
8.1.240.0090.00024.00
8.1.230.0070.00319.16
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0030.00617.60
8.1.190.0030.00617.76
8.1.180.0040.00418.10
8.1.170.0040.00418.81
8.1.160.0040.00422.20
8.1.150.0050.00218.94
8.1.140.0020.00517.70
8.1.130.0040.00418.00
8.1.120.0050.00317.53
8.1.110.0030.00617.63
8.1.100.0040.00417.70
8.1.90.0050.00217.67
8.1.80.0030.00317.63
8.1.70.0030.00317.57
8.1.60.0080.00017.77
8.1.50.0040.00417.71
8.1.40.0000.00717.73
8.1.30.0040.00417.70
8.1.20.0090.00017.76
8.1.10.0060.00317.73
8.1.00.0040.00417.67
8.0.300.0000.00718.77
8.0.290.0080.00017.41
8.0.280.0030.00318.60
8.0.270.0000.00717.43
8.0.260.0030.00317.13
8.0.250.0030.00317.19
8.0.240.0050.00217.11
8.0.230.0030.00517.26
8.0.220.0000.00717.14
8.0.210.0040.00417.18
8.0.200.0030.00317.20
8.0.190.0050.00317.14
8.0.180.0070.00017.25
8.0.170.0040.00417.16
8.0.160.0030.00617.16
8.0.150.0040.00417.18
8.0.140.0040.00417.18
8.0.130.0030.00313.64
8.0.120.0030.00617.14
8.0.110.0050.00317.09
8.0.100.0040.00417.09
8.0.90.0000.00717.08
8.0.80.0140.00717.25
8.0.70.0040.00417.20
8.0.60.0040.00417.15
8.0.50.0040.00417.00
8.0.30.0080.01217.52
8.0.20.0100.01017.46
8.0.10.0040.00417.27
8.0.00.0080.01017.08
7.4.330.0000.00515.31
7.4.320.0060.00016.69
7.4.300.0030.00316.86
7.4.290.0000.00716.63
7.4.280.0000.00716.83
7.4.270.0000.00716.86
7.4.260.0030.00716.84
7.4.250.0070.00016.73
7.4.240.0000.00716.77
7.4.230.0040.00416.95
7.4.220.0070.01516.93
7.4.210.0050.01116.83
7.4.200.0080.00016.84
7.4.190.0020.00516.61
7.4.160.0090.00616.66
7.4.150.0120.00617.40
7.4.140.0120.00517.86
7.4.130.0090.01016.79
7.4.120.0160.00716.74
7.4.110.0100.00716.59
7.4.100.0170.01916.77
7.4.90.0190.00016.57
7.4.80.0170.00016.81
7.4.70.0060.01316.86
7.4.60.0120.00416.57
7.4.50.0000.00816.89
7.4.40.0060.00922.77
7.4.30.0140.00716.76
7.4.00.0100.00314.94
7.3.330.0030.00313.66
7.3.320.0030.00313.47
7.3.310.0040.00416.66
7.3.300.0030.00316.45
7.3.290.0090.00916.63
7.3.280.0120.00616.62
7.3.270.0030.01317.40
7.3.260.0070.01016.55
7.3.250.0090.00816.72
7.3.240.0070.01016.78
7.3.230.0120.00616.67
7.3.210.0090.00916.75
7.3.200.0110.01119.39
7.3.190.0060.01116.66
7.3.180.0080.00816.88
7.3.170.0090.00616.58
7.3.160.0000.01516.78
7.3.120.0000.01615.04
7.2.330.0070.01017.00
7.2.320.0060.01216.94
7.2.310.0060.01216.66
7.2.300.0070.01016.68
7.2.290.0000.01616.88
7.2.60.0030.00917.09
7.2.00.0070.00719.48
7.1.200.0080.00415.62
7.1.100.0030.01218.36
7.1.70.0040.00417.10
7.1.60.0030.01019.22
7.1.50.0140.00716.82
7.1.00.0030.07722.51
7.0.200.0030.00516.87
7.0.140.0030.07322.15
7.0.60.0100.06319.87
7.0.50.0030.04717.87
7.0.40.0070.09020.33
7.0.30.0270.06320.23
7.0.20.0230.05020.20
7.0.10.0330.07020.28
7.0.00.0070.06320.37
5.6.280.0100.06721.02
5.6.210.0100.08320.88
5.6.200.0130.05718.31
5.6.190.0100.08020.77
5.6.180.0030.04020.85
5.6.170.0330.05720.57
5.6.160.0130.06020.62
5.6.150.0070.08718.36
5.6.140.0130.08018.29
5.6.130.0030.07718.25
5.6.120.0030.08021.05
5.6.110.0030.05021.22
5.6.100.0130.07721.04
5.6.90.0070.07321.12
5.6.80.0100.07020.45
5.6.70.4400.03020.57
5.5.350.0170.07020.43
5.5.340.0100.04318.07
5.5.330.0030.05320.54
5.5.320.0000.04720.38
5.5.310.0270.04020.49
5.5.300.0070.03718.02
5.5.290.0100.07718.07
5.5.280.0070.05321.07
5.5.270.0030.08320.87
5.5.260.0130.07021.03
5.5.250.0200.07020.66
5.5.240.0200.06720.42
5.4.450.0870.04019.63
5.4.440.0270.04719.54
5.4.430.0500.04719.36
5.4.420.0330.04319.48
5.4.410.0430.04719.33
5.4.400.0370.06718.75
5.4.390.0400.06718.56
5.4.380.0230.05018.59
5.4.370.0130.06318.81
5.4.360.0130.05318.93
5.4.350.0200.05318.88
5.4.340.0130.06018.86
5.4.320.0080.03412.67
5.4.310.0070.03612.66
5.4.300.0020.04112.67
5.4.290.0080.03612.66
5.4.280.0060.03412.56
5.4.270.0070.03412.56
5.4.260.0080.03512.56
5.4.250.0050.03812.56
5.4.240.0050.04112.55
5.4.230.0020.04112.55
5.4.220.0060.03512.55
5.4.210.0020.04012.55
5.4.200.0080.03512.55
5.4.190.0200.04412.54
5.4.180.0160.04612.53
5.4.170.0170.04412.54
5.4.160.0310.06112.54
5.4.150.0150.04412.54
5.4.140.0150.04212.22
5.4.130.0140.04512.21
5.4.120.0180.03912.17
5.4.110.0190.03812.16
5.4.100.0150.04312.16
5.4.90.0120.04612.16
5.4.80.0110.04712.16
5.4.70.0160.04012.16
5.4.60.0230.06312.16
5.4.50.0230.03512.16
5.4.40.0120.04412.15
5.4.30.0110.04812.15
5.4.20.0210.03812.15
5.4.10.0140.04512.14
5.4.00.0180.03911.63
5.3.290.0030.04112.93
5.3.280.0040.04012.86
5.3.270.0160.04612.85
5.3.260.0270.06412.86
5.3.250.0130.04912.85
5.3.240.0200.04712.85
5.3.230.0230.04512.85
5.3.220.0220.04112.82
5.3.210.0190.04212.82
5.3.200.0310.09112.81
5.3.190.0130.04912.82
5.3.180.0140.04512.82
5.3.170.0150.04612.81
5.3.160.0130.04612.81
5.3.150.0130.04512.81
5.3.140.0130.04612.80
5.3.130.0130.04712.80
5.3.120.0230.06912.79
5.3.110.0150.04812.80
5.3.100.0140.04612.29
5.3.90.0150.04412.27
5.3.80.0150.04412.25
5.3.70.0110.04812.26
5.3.60.0130.04612.23
5.3.50.0160.04312.18
5.3.40.0150.04412.18
5.3.30.0210.09712.15
5.3.20.0120.04511.92
5.3.10.0140.04211.89
5.3.00.0190.03911.88
5.2.170.0160.0309.37
5.2.160.0100.0369.37
5.2.150.0100.0379.37
5.2.140.0120.0359.37
5.2.130.0160.0309.33
5.2.120.0130.0339.33
5.2.110.0080.0409.33
5.2.100.0140.0329.33
5.2.90.0120.0339.33
5.2.80.0140.0329.32
5.2.70.0140.0339.32
5.2.60.0130.0329.27
5.2.50.0100.0379.24
5.2.40.0240.0569.22
5.2.30.0110.0359.20
5.2.20.0090.0429.19
5.2.10.0110.0349.09
5.2.00.0120.0378.95
5.1.60.0110.0298.25
5.1.50.0100.0308.24
5.1.40.0130.0278.23
5.1.30.0290.0738.58
5.1.20.0150.0308.60
5.1.10.0170.0258.16
5.1.00.0120.0298.16
5.0.50.0100.0236.66
5.0.40.0030.0286.50
5.0.30.0100.0336.32
5.0.20.0090.0226.29
5.0.10.0070.0246.27
5.0.00.0100.0336.25
4.4.90.0250.0624.78
4.4.80.0080.0174.75
4.4.70.0060.0224.76
4.4.60.0040.0234.76
4.4.50.0110.0144.77
4.4.40.0180.0494.71
4.4.30.0070.0184.76
4.4.20.0080.0164.84
4.4.10.0060.0184.85
4.4.00.0110.0264.76
4.3.110.0060.0194.66
4.3.100.0100.0164.66
4.3.90.0050.0184.63
4.3.80.0180.0774.58
4.3.70.0080.0164.63
4.3.60.0060.0184.63
4.3.50.0070.0184.63
4.3.40.0060.0284.54
4.3.30.0040.0193.30
4.3.20.0050.0193.28
4.3.10.0060.0183.24
4.3.00.0130.01015.46

preferences:
47.72 ms | 401 KiB | 5 Q