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'][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.70.0060.01218.68
8.3.60.0150.00617.25
8.3.50.0140.00716.85
8.3.40.0090.00619.04
8.3.30.0090.00918.92
8.3.20.0000.00818.96
8.3.10.0060.00320.91
8.3.00.0030.00719.63
8.2.180.0140.00717.00
8.2.170.0120.00322.96
8.2.160.0090.00619.25
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0030.00720.98
8.2.110.0060.00321.17
8.2.100.0030.01018.16
8.2.90.0060.00319.71
8.2.80.0050.00219.41
8.2.70.0060.00317.75
8.2.60.0040.00418.29
8.2.50.0050.00318.07
8.2.40.0040.00418.59
8.2.30.0000.01018.24
8.2.20.0000.00919.50
8.2.10.0040.00417.95
8.2.00.0070.00417.92
8.1.280.0070.01125.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0060.00328.09
8.1.240.0030.00622.79
8.1.230.0080.00421.16
8.1.220.0050.00317.91
8.1.210.0000.00819.15
8.1.200.0060.00317.48
8.1.190.0080.00017.78
8.1.180.0040.00418.10
8.1.170.0060.00319.22
8.1.160.0050.00219.19
8.1.150.0040.00418.76
8.1.140.0040.00417.64
8.1.130.0040.00417.59
8.1.120.0070.00017.58
8.1.110.0060.00317.67
8.1.100.0070.00017.56
8.1.90.0040.00417.70
8.1.80.0000.00717.77
8.1.70.0000.00717.59
8.1.60.0000.00817.69
8.1.50.0000.00717.65
8.1.40.0030.00517.65
8.1.30.0080.00017.86
8.1.20.0000.00817.70
8.1.10.0060.00317.82
8.1.00.0000.00817.71
8.0.300.0000.00719.91
8.0.290.0050.00316.88
8.0.280.0080.00318.68
8.0.270.0070.00017.48
8.0.260.0080.00017.00
8.0.250.0040.00417.21
8.0.240.0030.00317.14
8.0.230.0040.00317.14
8.0.220.0000.00717.05
8.0.210.0050.00317.16
8.0.200.0070.00317.05
8.0.190.0070.00017.09
8.0.180.0050.00317.14
8.0.170.0050.00516.97
8.0.160.0030.00417.05
8.0.150.0050.00317.11
8.0.140.0060.00317.03
8.0.130.0050.00013.53
8.0.120.0040.00417.05
8.0.110.0040.00417.17
8.0.100.0030.00616.99
8.0.90.0080.00017.17
8.0.80.0100.00617.04
8.0.70.0050.00216.99
8.0.60.0070.00017.05
8.0.50.0040.00416.99
8.0.30.0060.01217.51
8.0.20.0080.01117.30
8.0.10.0030.00517.07
8.0.00.0140.00716.88
7.4.330.0050.00013.27
7.4.320.0000.00716.84
7.4.300.0050.00216.68
7.4.290.0040.00416.71
7.4.280.0040.00416.70
7.4.270.0030.00316.68
7.4.260.0050.00013.38
7.4.250.0000.00916.70
7.4.240.0030.00516.85
7.4.230.0030.00316.94
7.4.220.0190.00016.74
7.4.210.0070.00716.82
7.4.200.0030.00316.95
7.4.190.0060.00316.77
7.4.160.0080.00816.74
7.4.150.0170.00016.54
7.4.140.0150.00316.69
7.4.130.0070.01016.75
7.4.120.0060.01016.90
7.4.110.0110.00716.79
7.4.100.0120.00616.79
7.4.90.0120.00616.78
7.4.80.0170.00719.39
7.4.70.0030.01416.52
7.4.60.0060.01216.66
7.4.50.0040.00416.67
7.4.40.0000.01616.52
7.4.30.0030.01317.01
7.4.10.0100.01016.85
7.4.00.0070.01015.94
7.3.330.0060.00013.57
7.3.320.0000.00613.38
7.3.310.0000.00716.40
7.3.300.0000.00716.45
7.3.290.0050.00916.55
7.3.280.0050.01116.60
7.3.270.0100.00716.68
7.3.260.0110.00616.52
7.3.250.0130.01916.71
7.3.240.0120.00916.71
7.3.230.0070.01216.59
7.3.210.0190.00016.73
7.3.200.0040.01216.86
7.3.190.0070.01516.84
7.3.180.0060.01516.54
7.3.170.0120.00316.68
7.3.160.0030.01316.88
7.3.130.0030.01716.53
7.3.120.0060.01115.80
7.3.110.0070.01316.64
7.3.100.0040.01116.87
7.3.90.0030.01316.55
7.3.80.0030.00716.80
7.3.70.0030.01316.72
7.3.60.0040.00816.50
7.3.50.0100.00616.47
7.3.40.0070.00716.51
7.3.30.0110.00816.62
7.3.20.0040.01218.46
7.3.10.0090.00618.30
7.3.00.0060.00618.54
7.2.330.0130.00716.95
7.2.320.0140.00617.10
7.2.310.0030.01416.91
7.2.300.0060.01217.05
7.2.290.0070.01416.98
7.2.260.0030.01516.67
7.2.250.0100.00316.82
7.2.240.0000.01516.69
7.2.230.0030.01316.79
7.2.220.0100.00716.64
7.2.210.0000.01317.09
7.2.200.0000.01216.99
7.2.190.0090.00616.63
7.2.180.0070.01117.00
7.2.170.0040.01216.69
7.2.160.0060.00616.69
7.2.150.0030.00918.71
7.2.140.0100.00718.53
7.2.130.0030.01318.61
7.2.120.0030.01418.69
7.2.110.0070.01018.56
7.2.100.0060.00918.59
7.2.90.0040.01218.50
7.2.80.0060.00618.47
7.2.70.0130.00318.75
7.2.60.0080.00517.79
7.2.50.0130.00517.78
7.2.40.0090.00618.70
7.2.30.0120.00418.63
7.2.20.0090.00918.59
7.2.10.0070.00718.52
7.2.00.0070.00718.57
7.1.330.0060.01217.67
7.1.320.0030.01317.51
7.1.310.0090.00617.70
7.1.300.0030.01317.53
7.1.290.0040.01417.52
7.1.280.0070.00717.56
7.1.270.0040.01117.57
7.1.260.0030.00917.53
7.1.250.0030.01317.41
7.1.240.0070.00717.63
7.1.230.0000.01217.56
7.1.220.0030.01317.63
7.1.210.0040.01117.47
7.1.200.0110.00516.62
7.1.190.0080.00817.39
7.1.180.0030.01017.55
7.1.170.0090.00317.51
7.1.160.0030.01017.61
7.1.150.0030.01317.60
7.1.140.0090.00617.45
7.1.130.0070.00717.46
7.1.120.0060.00617.39
7.1.110.0000.01017.56
7.1.100.0000.01317.66
7.1.90.0100.00317.41
7.1.80.0070.00717.39
7.1.70.0070.00417.41
7.1.60.0090.01118.30
7.1.50.0060.00617.09
7.1.40.0060.00917.40
7.1.30.0000.01017.64
7.1.20.0040.01117.52
7.1.10.0000.01417.75
7.1.00.0050.03320.11
7.0.330.0040.00817.28
7.0.320.0120.00317.22
7.0.310.0060.00617.16
7.0.300.0060.00917.32
7.0.290.0090.00917.28
7.0.280.0080.00417.38
7.0.270.0040.00517.16
7.0.260.0000.01217.28
7.0.250.0030.00917.27
7.0.240.0000.01617.27
7.0.230.0070.00717.24
7.0.220.0030.01017.27
7.0.210.0070.00417.26
7.0.200.0240.00516.01
7.0.190.0100.00317.15
7.0.180.0070.00417.25
7.0.170.0030.01017.23
7.0.160.0030.01017.38
7.0.150.0070.00717.24
7.0.140.0030.04219.60
7.0.130.0000.01717.09
7.0.120.0070.03519.69
7.0.110.0040.00717.32
7.0.100.0030.00917.36
7.0.90.0030.00617.19
7.0.80.0060.00617.18
7.0.70.0090.00617.17
7.0.60.0070.04318.75
7.0.50.0130.04017.64
7.0.40.0030.04816.56
7.0.30.0080.04216.57
7.0.20.0070.04616.50
7.0.10.0050.03816.47
7.0.00.0070.02716.48
5.6.400.0060.00616.14
5.6.390.0040.00816.29
5.6.380.0040.00716.14
5.6.370.0040.01216.54
5.6.360.0060.00615.95
5.6.350.0100.00316.15
5.6.340.0110.00416.05
5.6.330.0040.00816.25
5.6.320.0090.00616.14
5.6.310.0060.00616.11
5.6.300.0090.00616.17
5.6.290.0000.01115.98
5.6.280.0100.03518.77
5.6.270.0040.00716.45
5.6.260.0040.00716.17
5.6.250.0040.01116.10
5.6.240.0060.00916.13
5.6.230.0080.01116.08
5.6.220.0060.00916.34
5.6.210.0090.02818.54
5.6.200.0080.03517.24
5.6.190.0080.04717.20
5.6.180.0060.04217.34
5.6.170.0060.04317.24
5.6.160.0080.04217.06
5.6.150.0030.04117.26
5.6.140.0030.04717.26
5.6.130.0050.03517.18
5.6.120.0060.04617.22
5.6.110.0050.04617.39
5.6.100.0060.04417.28
5.6.90.0080.03217.21
5.6.80.0060.03316.84
5.6.70.0100.03516.98
5.6.60.0070.03416.90
5.6.50.0050.03516.92
5.6.40.0080.03816.85
5.6.30.0100.02216.88
5.6.20.0100.02116.85
5.6.10.0070.02216.80
5.6.00.0060.02716.90
5.5.380.0050.00516.25
5.5.370.0060.00316.33
5.5.360.0100.00315.99
5.5.350.0200.04318.40
5.5.340.0080.04817.11
5.5.330.0070.02717.06
5.5.320.0060.02217.13
5.5.310.0100.04217.08
5.5.300.0050.04417.04
5.5.290.0100.02717.10
5.5.280.0030.04017.02
5.5.270.0060.04317.18
5.5.260.0030.03517.06
5.5.250.0050.04017.03
5.5.240.0090.02316.71
5.5.230.0050.02716.75
5.5.220.0100.03316.88
5.5.210.0030.03016.79
5.5.200.0080.03716.71
5.5.190.0070.02316.78
5.5.180.0050.02216.77
5.5.170.0000.01215.87
5.5.160.0070.02416.85
5.5.150.0030.02616.82
5.5.140.0070.02516.77
5.5.130.0090.02416.63
5.5.120.0100.03716.84
5.5.110.0050.04216.85
5.5.100.0060.04616.74
5.5.90.0040.02616.77
5.5.80.0050.03816.77
5.5.70.0080.04216.63
5.5.60.0120.02416.72
5.5.50.0120.03616.63
5.5.40.0020.02816.58
5.5.30.0080.03316.69
5.5.20.0030.04016.69
5.5.10.0050.02216.67
5.5.00.0030.04716.61
5.4.450.0050.03916.16
5.4.440.0070.04316.31
5.4.430.0020.03516.14
5.4.420.0050.03816.25
5.4.410.0110.03916.29
5.4.400.0040.04215.98
5.4.390.0040.02516.03
5.4.380.0070.04016.11
5.4.370.0070.03316.06
5.4.360.0050.03315.98
5.4.350.0070.03016.06
5.4.340.0070.03215.98
5.4.330.0070.00312.93
5.4.320.0020.02715.99
5.4.310.0030.02016.09
5.4.300.0020.02316.07
5.4.290.0030.02816.00
5.4.280.0020.04116.04
5.4.270.0110.02615.99
5.4.260.0080.03715.99
5.4.250.0040.02716.19
5.4.240.0050.04016.02
5.4.230.0090.03916.09
5.4.220.0030.03816.00
5.4.210.0050.03115.96
5.4.200.0100.03816.07
5.4.190.0040.04416.07
5.4.180.0080.02316.07
5.4.170.0050.04216.06
5.4.160.0070.03516.05
5.4.150.0050.02616.03
5.4.140.0000.04314.78
5.4.130.0050.03114.75
5.4.120.0030.03214.62
5.4.110.0030.04214.78
5.4.100.0090.03714.78
5.4.90.0050.03314.73
5.4.80.0060.02614.67
5.4.70.0080.01914.59
5.4.60.0050.02214.82
5.4.50.0050.04014.70
5.4.40.0070.03214.70
5.4.30.0050.04314.70
5.4.20.0080.03014.61
5.4.10.0120.02514.75
5.4.00.0070.02414.42
5.3.290.0020.02714.20
5.3.280.0100.04214.11
5.3.270.0070.02714.03
5.3.260.0060.04013.98
5.3.250.0030.03814.08
5.3.240.0030.04113.95
5.3.230.0080.04314.05
5.3.220.0030.02813.90
5.3.210.0050.04213.87
5.3.200.0100.03713.87
5.3.190.0070.02113.96
5.3.180.0020.04414.13
5.3.170.0030.03714.15
5.3.160.0030.04113.96
5.3.150.0100.03814.14
5.3.140.0050.03514.10
5.3.130.0030.04013.97
5.3.120.0120.03814.03
5.3.110.0070.03013.87
5.3.100.0090.03113.69
5.3.90.0030.02713.70
5.3.80.0060.03813.56
5.3.70.0070.04013.58
5.3.60.0060.02413.76
5.3.50.0080.03313.71
5.3.40.0000.03213.65
5.3.30.0140.03513.64
5.3.20.0050.04213.49
5.3.10.0070.01813.45
5.3.00.0050.02813.41
5.2.170.0100.06011.29
5.2.160.0030.04011.30
5.2.150.0070.06011.24
5.2.140.0000.06311.14
5.2.130.0030.03311.26
5.2.120.0030.03011.11
5.2.110.0000.03711.27
5.2.100.0030.06311.09
5.2.90.0070.06011.35
5.2.80.0030.05011.41
5.2.70.0030.05011.34
5.2.60.0030.03711.19
5.2.50.0000.03711.17
5.2.40.0030.06011.24
5.2.30.0070.06311.10
5.2.20.0070.05011.11
5.2.10.0030.06311.11
5.2.00.0030.06010.86
5.1.60.0070.04310.30
5.1.50.0030.03010.13
5.1.40.0100.0439.97
5.1.30.0070.04310.46
5.1.20.0030.03710.35
5.1.10.0000.02710.07
5.1.00.0100.03310.17
5.0.50.0100.0408.61
5.0.40.0100.0208.65
5.0.30.0000.0638.29
5.0.20.0030.0408.21
5.0.10.0000.0378.20
5.0.00.0000.0638.15
4.4.90.0030.0237.57
4.4.80.0000.0237.57
4.4.70.0030.0377.57
4.4.60.0070.0337.57
4.4.50.0000.0307.57
4.4.40.0000.0377.57
4.4.30.0030.0177.57
4.4.20.0030.0177.57
4.4.10.0030.0337.57
4.4.00.0000.0407.57
4.3.110.0000.0407.57
4.3.100.0000.0177.57
4.3.90.0100.0307.57
4.3.80.0000.0337.57
4.3.70.0030.0307.57
4.3.60.0070.0207.57
4.3.50.0030.0307.57
4.3.40.0070.0477.57
4.3.30.0000.0377.57
4.3.20.0030.0377.57
4.3.10.0030.0337.57
4.3.00.0030.0237.57

preferences:
46.34 ms | 401 KiB | 5 Q