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(); $parent = $this->xml->xpath('../'); $parent = $parent[0]; $target = $parent->xpath($tag . '[' . $offset . ']'); $target = $target[0]; return new self($target->asXML(), false); } 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']; var_dump($xml['note']['recursive']);

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.0070.01016.88
8.3.50.0130.00516.95
8.3.40.0070.01018.94
8.3.30.0110.00418.97
8.3.20.0050.00319.10
8.3.10.0050.00319.01
8.3.00.0040.00419.63
8.2.180.0120.00325.92
8.2.170.0140.00719.34
8.2.160.0100.00322.96
8.2.150.0080.00025.66
8.2.140.0030.00524.66
8.2.130.0030.00626.16
8.2.120.0060.00320.88
8.2.110.0030.00721.29
8.2.100.0090.00318.16
8.2.90.0000.00819.42
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0050.00318.30
8.2.50.0030.00518.18
8.2.40.0030.00620.07
8.2.30.0030.00617.89
8.2.20.0080.00417.86
8.2.10.0040.00418.09
8.2.00.0000.00818.04
8.1.280.0120.00925.92
8.1.270.0050.00323.99
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0090.00021.23
8.1.230.0070.00422.12
8.1.220.0040.00417.93
8.1.210.0080.00018.77
8.1.200.0090.00017.63
8.1.190.0000.00917.60
8.1.180.0040.00418.10
8.1.170.0030.00517.62
8.1.160.0000.00719.30
8.1.150.0040.00418.87
8.1.140.0040.00417.77
8.1.130.0000.00718.05
8.1.120.0000.00717.70
8.1.110.0030.00617.71
8.1.100.0000.00717.78
8.1.90.0060.00317.77
8.1.80.0040.00417.82
8.1.70.0040.00417.65
8.1.60.0060.00617.91
8.1.50.0080.00017.77
8.1.40.0030.00617.77
8.1.30.0050.00317.77
8.1.20.0040.00717.89
8.1.10.0040.00417.75
8.1.00.0040.00417.79
8.0.300.0000.00818.77
8.0.290.0040.00416.88
8.0.280.0000.00718.81
8.0.270.0040.00417.58
8.0.260.0030.00317.07
8.0.250.0000.00717.20
8.0.240.0030.00517.27
8.0.230.0030.00617.19
8.0.220.0070.00017.06
8.0.210.0030.00517.22
8.0.200.0060.00017.16
8.0.190.0040.00417.27
8.0.180.0040.00417.22
8.0.170.0000.00817.05
8.0.160.0070.00017.16
8.0.150.0000.00917.20
8.0.140.0060.00317.04
8.0.130.0030.00313.59
8.0.120.0030.00617.11
8.0.110.0040.00417.02
8.0.100.0000.00717.00
8.0.90.0060.00317.13
8.0.80.0100.00717.16
8.0.70.0040.00417.16
8.0.60.0080.00017.23
8.0.50.0030.00517.23
8.0.30.0150.00317.16
8.0.20.0140.00517.25
8.0.10.0040.00417.18
8.0.00.0130.00617.06
7.4.330.0000.00613.16
7.4.320.0070.00016.89
7.4.300.0000.00716.68
7.4.290.0030.00316.81
7.4.280.0040.00416.91
7.4.270.0040.00416.95
7.4.260.0000.00513.52
7.4.250.0050.00316.81
7.4.240.0030.00516.77
7.4.230.0030.00316.84
7.4.220.0100.01616.94
7.4.210.0120.00316.71
7.4.200.0000.00716.92
7.4.190.0070.00016.68
7.4.160.0090.00616.58
7.4.150.0120.00616.86
7.4.140.0090.00916.76
7.4.130.0100.00716.73
7.4.120.0090.00916.54
7.4.110.0090.01216.72
7.4.100.0130.00616.83
7.4.90.0090.00916.73
7.4.80.0140.01116.62
7.4.70.0070.01016.79
7.4.60.0080.00916.87
7.4.50.0060.00616.68
7.4.40.0070.00716.82
7.4.30.0080.00816.57
7.4.00.0080.01015.06
7.3.330.0030.00313.62
7.3.320.0050.00013.43
7.3.310.0040.00416.63
7.3.300.0000.00716.68
7.3.290.0110.00616.64
7.3.280.0090.01016.61
7.3.270.0150.00416.85
7.3.260.0100.00716.65
7.3.250.0150.01016.68
7.3.240.0160.00316.94
7.3.230.0080.00816.82
7.3.210.0030.01316.79
7.3.200.0130.00919.39
7.3.190.0130.01016.64
7.3.180.0100.00716.63
7.3.170.0070.01516.96
7.3.160.0110.00716.75
7.3.120.0060.00915.17
7.3.110.0000.01515.24
7.3.100.0000.01315.01
7.3.90.0060.00915.01
7.3.80.0070.01115.09
7.3.70.0030.00615.03
7.3.60.0110.00014.98
7.3.50.0000.01315.04
7.3.40.0030.00714.82
7.3.30.0080.00414.71
7.3.20.0110.00416.80
7.3.10.0060.01016.51
7.3.00.0100.00616.55
7.2.330.0070.01316.76
7.2.320.0150.00316.82
7.2.310.0070.01116.73
7.2.300.0170.00017.15
7.2.290.0100.00716.86
7.2.250.0160.00315.40
7.2.240.0100.00715.24
7.2.230.0150.00315.29
7.2.220.0070.01015.10
7.2.210.0000.01215.15
7.2.200.0070.00715.04
7.2.190.0110.00415.19
7.2.180.0060.00615.28
7.2.170.0030.00915.18
7.2.130.0140.00416.65
7.2.120.0100.00816.91
7.2.110.0080.00916.77
7.2.100.0130.01016.83
7.2.90.0160.00816.88
7.2.80.0090.00716.79
7.2.70.0160.00816.99
7.2.60.0140.01016.85
7.2.50.0140.00816.89
7.2.40.0120.00816.96
7.2.30.0060.01016.84
7.2.20.0020.01016.83
7.2.10.0040.01016.77
7.2.00.0060.00817.67
7.1.330.0000.01315.80
7.1.320.0060.00816.09
7.1.310.0080.00415.97
7.1.300.0080.00416.02
7.1.290.0050.00515.93
7.1.280.0130.00015.98
7.1.270.0070.00715.93
7.1.260.0090.00016.04
7.1.250.0160.00515.81
7.1.100.0070.00418.13
7.1.70.0040.00417.48
7.1.60.0130.01319.30
7.1.50.0100.01016.91
7.1.00.0030.07722.59
7.0.200.0170.00016.72
7.0.140.0000.07022.15
7.0.120.0030.03322.20
7.0.60.0100.05319.99
7.0.50.0070.07717.98
7.0.40.0070.09020.27
7.0.30.0330.07320.32
7.0.20.0400.07020.23
7.0.10.0030.07020.34
7.0.00.0070.08320.40
5.6.280.0100.07021.07
5.6.210.0030.06720.92
5.6.200.0030.04318.30
5.6.190.0200.06020.78
5.6.180.0400.04720.82
5.6.170.0400.05020.70
5.6.160.0030.05720.61
5.6.150.0070.08018.39
5.6.140.0100.05018.36
5.6.130.0130.08018.33
5.6.120.0170.06020.98
5.6.110.0070.08721.24
5.6.100.0000.09021.05
5.6.90.0070.07021.23
5.6.80.0070.06320.54
5.5.350.4300.03720.56
5.5.340.0100.04718.06
5.5.330.0100.08320.22
5.5.320.0470.04720.39
5.5.310.0100.05020.43
5.5.300.0070.07318.11
5.5.290.0100.04318.06
5.5.280.0130.05320.94
5.5.270.0070.05320.86
5.5.260.0030.06720.88
5.5.250.0170.04720.71
5.5.240.0130.08020.42
5.4.450.0530.05019.49
5.4.440.0330.04719.47
5.4.430.0470.03319.63
5.4.420.0400.03719.40
5.4.410.0400.03019.37
5.4.400.0400.04719.33
5.4.390.0470.04019.14
5.4.380.0430.07019.34
5.4.370.0400.04319.34
5.4.360.0470.03319.11
5.4.350.0500.06019.34
5.4.340.0470.03719.34
5.4.320.0600.05719.09
5.4.310.0470.06319.34
5.4.300.0530.06719.14
5.4.290.0530.04319.34
5.4.280.0500.07019.21
5.4.270.0570.06319.30
5.4.260.0570.06319.13
5.4.250.0500.04719.32
5.4.240.0570.05719.21
5.4.230.0430.07019.34
5.4.220.0530.06319.32
5.4.210.0630.04319.05
5.4.200.0470.07319.34
5.4.190.0400.03719.14
5.4.180.0470.06319.30
5.4.170.0230.03719.32
5.4.160.0530.06319.19
5.4.150.0400.04319.09
5.4.140.0530.06316.55
5.4.130.0570.06316.64
5.4.120.0530.05316.64
5.4.110.0470.04716.38
5.4.100.0530.05316.72
5.4.90.0530.06316.70
5.4.80.0400.03716.70
5.4.70.0470.03016.37
5.4.60.0600.05316.69
5.4.50.0500.06316.51
5.4.40.0330.04316.36
5.4.30.0500.04016.44
5.4.20.0530.06316.70
5.4.10.0570.05716.49
5.4.00.0470.05016.05
5.3.290.0470.04314.74
5.3.280.0470.07314.86
5.3.270.0370.04014.79
5.3.260.0430.04314.93
5.3.250.0570.06014.67
5.3.240.0600.03714.90
5.3.230.0500.05714.68
5.3.220.0430.05014.78
5.3.210.0470.03314.79
5.3.200.0570.06014.83
5.3.190.0430.05314.64
5.3.180.0470.05314.78
5.3.170.0430.03314.74
5.3.160.0500.05314.74
5.3.150.0470.03714.63
5.3.140.0530.06314.75
5.3.130.0530.05714.77
5.3.120.0430.05314.80
5.3.110.0470.05014.78
5.3.100.0670.03714.11
5.3.90.0470.07014.28
5.3.80.0630.05314.29
5.3.70.0630.05314.06
5.3.60.0500.06714.07
5.3.50.0500.04714.17
5.3.40.0500.04313.98
5.3.30.0670.05013.98
5.3.20.0630.05313.77
5.3.10.0500.06013.68
5.3.00.0530.05713.75
5.2.170.0400.04711.72
5.2.160.0430.04011.72
5.2.150.0500.04311.72
5.2.140.0400.02311.72
5.2.130.0630.02311.72
5.2.120.0400.04711.72
5.2.110.0370.03711.72
5.2.100.0370.04011.72
5.2.90.0430.05311.72
5.2.80.0330.03311.72
5.2.70.0400.02711.72
5.2.60.0500.04711.72
5.2.50.0470.04311.72
5.2.40.0400.05011.72
5.2.30.0300.03011.72
5.2.20.0230.03011.72
5.2.10.0230.02711.72
5.2.00.0170.03311.72
5.1.60.0170.02011.72
5.1.50.0130.02311.72
5.1.40.0130.02311.73
5.1.30.0170.02011.74
5.1.20.0130.02711.75
5.1.10.0170.02711.76
5.1.00.0300.02711.77
5.0.50.0070.02011.77
5.0.40.0070.02011.78
5.0.30.0030.03311.78
5.0.20.0070.02011.81
5.0.10.0100.01711.84
5.0.00.0030.03311.84
4.4.90.0130.02011.72
4.4.80.0200.03011.72
4.4.70.0130.01711.72
4.4.60.0100.01711.72
4.4.50.0100.01711.72
4.4.40.0070.02311.72
4.4.30.0070.01311.73
4.4.20.0070.01311.75
4.4.10.0070.01311.77
4.4.00.0070.02311.78
4.3.110.0030.01711.78
4.3.100.0100.01711.80
4.3.90.0030.02011.83
4.3.80.0030.02711.88
4.3.70.0130.01011.88
4.3.60.0070.01311.88
4.3.50.0070.01711.88
4.3.40.0030.02711.89
4.3.30.0070.01311.89
4.3.20.0070.03011.90
4.3.10.0030.01711.90
4.3.00.0030.02011.91

preferences:
49.68 ms | 401 KiB | 5 Q