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; } return (array) $this->xml->$offset;//new self($this->xml->$offset->asXML(), false); } public function __toString() { var_dump($this->xml->$offset);die; return (string) $this->xml->$offset; } 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.0090.00618.53
8.3.50.0120.00522.09
8.3.40.0140.00018.88
8.3.30.0070.00719.34
8.3.20.0070.00020.64
8.3.10.0040.00423.73
8.3.00.0080.00022.69
8.2.180.0030.01218.66
8.2.170.0110.00422.96
8.2.160.0100.00320.55
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0110.00326.16
8.2.120.0070.00022.38
8.2.110.0030.00722.34
8.2.100.0080.00418.22
8.2.90.0030.00618.09
8.2.80.0000.00817.97
8.2.70.0000.00917.74
8.2.60.0050.00518.18
8.2.50.0040.00418.07
8.2.40.0000.00819.36
8.2.30.0040.00418.33
8.2.20.0070.00017.82
8.2.10.0000.00919.72
8.2.00.0040.00418.04
8.1.280.0100.00725.92
8.1.270.0050.00322.45
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0100.00722.27
8.1.230.0110.00417.48
8.1.220.0000.00817.91
8.1.210.0060.00319.22
8.1.200.0060.00317.48
8.1.190.0030.00517.78
8.1.180.0000.00818.10
8.1.170.0000.00918.79
8.1.160.0000.00822.08
8.1.150.0000.00818.76
8.1.140.0050.00317.71
8.1.130.0050.00317.90
8.1.120.0000.00817.76
8.1.110.0000.00817.73
8.1.100.0070.00017.62
8.1.90.0030.00517.62
8.1.80.0000.00717.74
8.1.70.0070.00017.68
8.1.60.0030.00617.86
8.1.50.0030.00617.79
8.1.40.0000.00817.74
8.1.30.0000.00817.69
8.1.20.0030.00517.89
8.1.10.0030.00517.75
8.1.00.0030.00717.68
8.0.300.0040.00420.25
8.0.290.0050.00217.30
8.0.280.0050.00218.63
8.0.270.0070.00017.39
8.0.260.0000.00717.01
8.0.250.0030.00317.18
8.0.240.0040.00417.16
8.0.230.0040.00417.18
8.0.220.0040.00417.20
8.0.210.0030.00617.08
8.0.200.0000.00817.20
8.0.190.0030.00617.17
8.0.180.0040.00417.18
8.0.170.0000.00817.25
8.0.160.0000.00717.15
8.0.150.0040.00417.05
8.0.140.0040.00417.17
8.0.130.0050.00313.54
8.0.120.0000.00817.06
8.0.110.0040.00417.17
8.0.100.0040.00417.25
8.0.90.0050.00216.94
8.0.80.0110.01117.05
8.0.70.0040.00416.98
8.0.60.0000.00717.16
8.0.50.0070.00017.09
8.0.30.0100.01017.36
8.0.20.0110.00717.48
8.0.10.0000.00717.06
8.0.00.0110.01117.21
7.4.330.0020.00215.23
7.4.320.0060.00016.69
7.4.300.0030.00616.78
7.4.290.0030.00316.82
7.4.280.0000.00716.74
7.4.270.0030.00616.74
7.4.260.0000.00816.79
7.4.250.0000.00816.63
7.4.240.0000.00716.78
7.4.230.0040.00416.70
7.4.220.0030.01516.72
7.4.210.0080.00816.86
7.4.200.0030.00316.93
7.4.190.0000.00716.73
7.4.160.0170.00616.79
7.4.150.0080.00817.40
7.4.140.0190.01617.86
7.4.130.0060.01216.90
7.4.120.0170.00716.76
7.4.110.0060.01116.64
7.4.100.0140.00816.70
7.4.90.0040.01316.83
7.4.80.0060.01219.39
7.4.70.0110.00816.92
7.4.60.0160.00016.51
7.4.50.0000.00816.87
7.4.40.0030.01622.77
7.4.30.0030.01416.76
7.4.00.0040.00714.98
7.3.330.0040.00413.73
7.3.320.0050.00013.52
7.3.310.0030.00316.54
7.3.300.0050.00216.59
7.3.290.0070.00716.71
7.3.280.0070.01016.63
7.3.270.0040.01417.40
7.3.260.0140.00416.91
7.3.250.0050.01216.72
7.3.240.0110.00716.84
7.3.230.0070.01016.61
7.3.210.0100.01316.64
7.3.200.0100.00719.39
7.3.190.0180.00316.71
7.3.180.0100.00616.60
7.3.170.0030.01216.65
7.3.160.0060.01016.74
7.3.120.0040.01115.12
7.3.00.0090.00316.30
7.2.330.0100.01316.90
7.2.320.0120.00616.94
7.2.310.0130.01016.96
7.2.300.0080.00817.02
7.2.290.0080.01116.88
7.2.130.0070.01016.38
7.2.120.0030.01016.75
7.2.110.0060.01216.52
7.2.100.0070.00716.88
7.2.90.0080.00517.33
7.2.80.0100.00616.98
7.2.70.0090.00916.91
7.2.60.0050.00716.97
7.2.50.0120.00016.94
7.2.40.0100.00717.10
7.2.30.0030.01217.33
7.2.20.0070.00716.72
7.2.10.0100.00616.69
7.2.00.0080.01616.79
7.1.250.0100.00315.53
7.1.240.0070.00715.74
7.1.230.0070.00715.75
7.1.220.0030.00615.72
7.1.210.0060.00615.78
7.1.200.0130.00215.82
7.1.190.0070.01015.67
7.1.180.0060.00315.81
7.1.170.0060.00815.88
7.1.160.0080.00815.69
7.1.150.0040.01215.78
7.1.140.0050.00515.69
7.1.130.0040.01115.54
7.1.120.0040.00915.54
7.1.110.0060.00915.82
7.1.100.0040.00815.77
7.1.90.0000.01415.43
7.1.80.0070.00315.80
7.1.70.0000.01116.63
7.1.60.0110.00817.46
7.1.50.0070.01016.56
7.1.40.0100.01015.76
7.1.30.0060.00615.63
7.1.20.0070.00715.76
7.1.10.0030.01415.79
7.1.00.0080.04019.12
7.0.330.0060.00615.34
7.0.320.0040.01115.43
7.0.310.0050.00514.92
7.0.300.0060.00615.58
7.0.290.0030.00915.09
7.0.280.0060.00315.02
7.0.270.0070.00715.31
7.0.260.0000.01414.98
7.0.250.0000.00915.24
7.0.240.0110.00315.21
7.0.230.0030.00615.30
7.0.220.0080.00015.59
7.0.210.0070.00715.25
7.0.200.0090.00316.20
7.0.190.0040.00415.53
7.0.180.0030.01015.47
7.0.170.0000.01515.47
7.0.160.0190.00315.50
7.0.150.0070.00715.27
7.0.140.0050.03818.80
7.0.130.0090.00915.27
7.0.120.0060.00615.14
7.0.110.0060.00915.05
7.0.100.0030.00715.03
7.0.90.0100.00715.21
7.0.80.0140.00315.46
7.0.70.0070.03018.59
7.0.60.0040.03718.57
7.0.50.0060.04518.89
7.0.40.0030.04416.92
7.0.30.0050.03716.75
7.0.20.0030.03816.84
7.0.10.0070.04316.88
7.0.00.0060.04416.68
5.6.380.0030.01014.77
5.6.370.0030.00614.46
5.6.360.0040.01114.44
5.6.350.0030.01614.70
5.6.340.0030.01214.36
5.6.330.0030.00914.52
5.6.320.0080.00414.32
5.6.310.0030.01014.20
5.6.300.0070.01014.54
5.6.290.0030.01014.14
5.6.280.0040.04217.91
5.6.270.0060.00914.86
5.6.260.0000.01314.52
5.6.250.0130.00014.66
5.6.240.0080.00614.86
5.6.230.0030.01014.49
5.6.220.0080.04417.73
5.6.210.0020.04817.50
5.6.200.0070.04517.87
5.6.190.0060.04717.82
5.6.180.0060.02717.93
5.6.170.0020.03017.97
5.6.160.0100.03817.75
5.6.150.0040.04117.74
5.6.140.0060.04117.88
5.6.130.0050.04517.96
5.6.120.0050.02817.96
5.6.110.0000.04918.06
5.6.100.0050.04717.76
5.6.90.0030.05017.89
5.6.80.0010.02317.50
5.6.70.0020.02817.56
5.6.60.0060.04117.40
5.6.50.0070.04017.59
5.6.40.0060.03817.38
5.6.30.0100.03417.46
5.6.20.0030.04717.43
5.6.10.0080.03617.39
5.6.00.0110.03817.63
5.5.380.0100.00011.27
5.5.370.0050.00510.96
5.5.360.0050.04615.79
5.5.350.0090.03515.90
5.5.340.0000.05016.12
5.5.330.0050.04616.10
5.5.320.0050.04315.92
5.5.310.0010.02316.26
5.5.300.0060.03316.09
5.5.290.0030.04516.12
5.5.280.0050.04516.08
5.5.270.0030.04316.11
5.5.260.0050.04016.05
5.5.250.0060.03015.98
5.5.240.0040.02015.64
5.5.230.0050.04015.84
5.5.220.0030.03415.69
5.5.210.0000.04315.73
5.5.200.0030.03715.84
5.5.190.0080.04215.74
5.5.180.0020.04515.68
5.5.170.0050.00210.93
5.5.160.0070.04015.62
5.5.150.0050.04315.69
5.5.140.0000.03615.79
5.5.130.0020.03315.73
5.5.120.0060.03615.64
5.5.110.0050.04315.78
5.5.100.0120.03715.66
5.5.90.0040.03015.57
5.5.80.0030.03815.65
5.5.70.0020.04415.75
5.5.60.0090.03015.81
5.5.50.0020.03815.66
5.5.40.0030.04415.62
5.5.30.0060.04115.69
5.5.20.0050.03315.86
5.5.10.0020.03815.83
5.5.00.0050.04215.69
5.4.450.0050.04315.28
5.4.440.0000.04715.42
5.4.430.0030.04115.49
5.4.420.0050.04015.44
5.4.410.0080.02215.33
5.4.400.0030.02415.11
5.4.390.0060.03715.10
5.4.380.0020.02715.15
5.4.370.0050.03215.12
5.4.360.0000.04415.16
5.4.350.0020.03915.11
5.4.340.0040.03415.25
5.4.330.0060.00311.26
5.4.320.0030.03814.96
5.4.310.0030.04015.19
5.4.300.0020.04415.26
5.4.290.0080.03315.09
5.4.280.0030.04615.22
5.4.270.0050.03515.05
5.4.260.0040.04415.22
5.4.250.0070.03014.93
5.4.240.0020.03315.20
5.4.230.0030.04315.06
5.4.220.0080.03515.09
5.4.210.0060.04515.15
5.4.200.0040.03515.10
5.4.190.0020.03515.03
5.4.180.0070.03515.27
5.4.170.0040.04215.05
5.4.160.0110.03515.21
5.4.150.0060.03515.12
5.4.140.0080.02713.90
5.4.130.0060.03913.86
5.4.120.0030.03813.91
5.4.110.0000.04413.74
5.4.100.0000.04113.96
5.4.90.0040.02713.98
5.4.80.0060.03813.72
5.4.70.0020.03813.80
5.4.60.0080.03613.81
5.4.50.0050.03713.96
5.4.40.0030.02913.76
5.4.30.0020.04113.96
5.4.20.0050.02813.70
5.4.10.0040.03913.79
5.4.00.0040.03513.41
5.3.290.0050.03212.77
5.3.280.0050.04012.66
5.3.270.0030.03112.80
5.3.260.0000.04312.86
5.3.250.0060.03512.64
5.3.240.0020.04312.62
5.3.230.0040.04012.77
5.3.220.0030.03612.57
5.3.210.0030.04012.56
5.3.200.0080.03312.60
5.3.190.0070.03712.69
5.3.180.0000.04012.83
5.3.170.0050.04312.75
5.3.160.0030.03812.77
5.3.150.0060.03812.79
5.3.140.0030.04112.84
5.3.130.0020.04212.62
5.3.120.0030.03812.75
5.3.110.0010.02312.71
5.3.100.0050.03012.45
5.3.90.0040.03812.34
5.3.80.0070.03712.36
5.3.70.0070.03712.28
5.3.60.0000.04112.40
5.3.50.0030.03312.41
5.3.40.0070.02312.20
5.3.30.0050.01712.36
5.3.20.0000.03412.18
5.3.10.0020.03912.14
5.3.00.0020.02512.10
5.2.170.0020.03811.02
5.2.160.0030.02910.96
5.2.150.0020.01710.96
5.2.140.0030.03210.97
5.2.130.0030.03310.84
5.2.120.0020.02610.95
5.2.110.0030.03310.93
5.2.100.0050.02010.95
5.2.90.0000.01810.84
5.2.80.0050.02510.87
5.2.70.0020.02010.87
5.2.60.0060.01210.88
5.2.50.0020.01810.84
5.2.40.0040.02510.89
5.2.30.0020.03510.91
5.2.20.0070.01310.84
5.2.10.0020.02010.84
5.2.00.0020.03110.84
5.1.60.0020.02010.84
5.1.50.0050.02710.84
5.1.40.0020.02810.84
5.1.30.0040.03210.84
5.1.20.0030.02810.84
5.1.10.0030.02310.84
5.1.00.0030.03010.84
5.0.50.0000.02710.84
5.0.40.0030.02110.84
5.0.30.0040.03310.84
5.0.20.0030.02410.84
5.0.10.0010.02010.84
5.0.00.0030.03310.84
4.4.90.0010.00910.84
4.4.80.0030.00710.84
4.4.70.0020.01710.84
4.4.60.0020.00810.84
4.4.50.0010.01810.84
4.4.40.0070.02510.84
4.4.30.0000.02010.84
4.4.20.0000.02110.84
4.4.10.0030.01810.84
4.4.00.0020.03010.84
4.3.110.0020.01010.84
4.3.100.0020.01810.84
4.3.90.0020.01610.84
4.3.80.0020.02910.84
4.3.70.0020.01810.84
4.3.60.0000.02110.84
4.3.50.0030.01910.84
4.3.40.0010.02510.84
4.3.30.0000.01510.84
4.3.20.0010.02110.84
4.3.10.0020.01910.84
4.3.00.0030.01510.84

preferences:
51.3 ms | 400 KiB | 5 Q