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); var_dump($this->xml->xpath('/note/recursive/val[2]'));die; } 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 . '[' . $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']; echo $xml['note']['recursive']['val'][1];

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.81
8.3.50.0070.01217.79
8.3.40.0120.00319.19
8.3.30.0000.01518.96
8.3.20.0060.00319.33
8.3.10.0080.00021.04
8.3.00.0040.00419.51
8.2.180.0080.00817.13
8.2.170.0070.00722.96
8.2.160.0070.00722.49
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00820.20
8.2.110.0080.00321.49
8.2.100.0060.00618.16
8.2.90.0000.00919.56
8.2.80.0080.00018.18
8.2.70.0060.00317.75
8.2.60.0030.00518.18
8.2.50.0040.00418.07
8.2.40.0040.00418.41
8.2.30.0000.00718.27
8.2.20.0030.00518.00
8.2.10.0050.00318.27
8.2.00.0060.00318.02
8.1.280.0040.01125.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00321.26
8.1.230.0040.00721.34
8.1.220.0090.00018.77
8.1.210.0040.00419.35
8.1.200.0100.00017.73
8.1.190.0030.00518.00
8.1.180.0080.00018.10
8.1.170.0000.00819.19
8.1.160.0040.00419.26
8.1.150.0080.00019.03
8.1.140.0030.00617.86
8.1.130.0030.00318.26
8.1.120.0000.00717.71
8.1.110.0000.00717.73
8.1.100.0000.00717.84
8.1.90.0050.00317.67
8.1.80.0000.00817.59
8.1.70.0030.00317.68
8.1.60.0000.00918.03
8.1.50.0000.00817.88
8.1.40.0000.00917.87
8.1.30.0080.00018.00
8.1.20.0050.00317.90
8.1.10.0040.00418.00
8.1.00.0040.00417.72
8.0.300.0070.00020.33
8.0.290.0020.00516.88
8.0.280.0070.00018.73
8.0.270.0000.00717.67
8.0.260.0000.00717.25
8.0.250.0050.00317.48
8.0.240.0090.00017.30
8.0.230.0030.00317.38
8.0.220.0030.00317.15
8.0.210.0040.00417.32
8.0.200.0040.00417.41
8.0.190.0000.00817.48
8.0.180.0040.00417.21
8.0.170.0040.00417.20
8.0.160.0030.00617.36
8.0.150.0000.00917.19
8.0.140.0000.00717.18
8.0.130.0000.00513.76
8.0.120.0000.00717.20
8.0.110.0000.00817.26
8.0.100.0050.00217.21
8.0.90.0000.00717.24
8.0.80.0030.01217.38
8.0.70.0030.00517.29
8.0.60.0070.00017.28
8.0.50.0000.00817.19
8.0.30.0130.00817.51
8.0.20.0170.00717.43
8.0.10.0000.00717.44
8.0.00.0140.00617.30
7.4.330.0020.00313.48
7.4.320.0000.00616.79
7.4.300.0030.00316.84
7.4.290.0000.00816.83
7.4.280.0070.00416.82
7.4.270.0050.00216.90
7.4.260.0000.00613.59
7.4.250.0030.00516.73
7.4.240.0070.00016.75
7.4.230.0000.00716.76
7.4.220.0060.01816.94
7.4.210.0050.01116.92
7.4.200.0030.00516.64
7.4.190.0000.00716.94
7.4.160.0060.00917.00
7.4.150.0140.00716.99
7.4.140.0120.00816.83
7.4.130.0140.00316.92
7.4.120.0100.00816.99
7.4.110.0090.01216.84
7.4.100.0060.01217.05
7.4.90.0090.00917.05
7.4.80.0030.01716.73
7.4.70.0030.01416.93
7.4.60.0140.00317.02
7.4.50.0090.00016.66
7.4.40.0100.00316.71
7.4.30.0070.01316.84
7.4.00.0040.01115.31
7.3.330.0060.00013.80
7.3.320.0030.00313.79
7.3.310.0000.00716.85
7.3.300.0070.00016.65
7.3.290.0100.01316.79
7.3.280.0070.00916.69
7.3.270.0120.00916.76
7.3.260.0050.01216.91
7.3.250.0060.01416.99
7.3.240.0080.00816.81
7.3.230.0120.00616.85
7.3.210.0040.01316.82
7.3.200.0100.00719.39
7.3.190.0040.01316.70
7.3.180.0130.00316.86
7.3.170.0120.00616.78
7.3.160.0140.00416.92
7.3.120.0100.00715.04
7.3.00.0030.00816.86
7.2.330.0130.01017.17
7.2.320.0150.00917.10
7.2.310.0100.01017.14
7.2.300.0120.00416.91
7.2.290.0120.01217.18
7.2.130.0040.01116.92
7.2.120.0100.00317.18
7.2.110.0060.00917.02
7.2.100.0030.00817.10
7.2.90.0040.01117.07
7.2.80.0040.00716.94
7.2.70.0080.00017.29
7.2.60.0070.00717.18
7.2.50.0070.00716.89
7.2.40.0050.00317.00
7.2.30.0060.00617.18
7.2.20.0060.00617.24
7.2.10.0030.00616.84
7.2.00.0080.00618.29
7.1.250.0000.01315.81
7.1.240.0000.01015.99
7.1.230.0130.00016.01
7.1.220.0080.00615.90
7.1.210.0040.01115.75
7.1.200.0070.00715.84
7.1.190.0030.01015.63
7.1.180.0100.00015.93
7.1.170.0040.00415.91
7.1.160.0040.00815.88
7.1.150.0120.00315.92
7.1.140.0000.01515.88
7.1.130.0070.00715.79
7.1.120.0030.00615.75
7.1.110.0030.00516.01
7.1.100.0080.00216.95
7.1.90.0060.00915.92
7.1.80.0080.00315.92
7.1.70.0040.00516.71
7.1.60.0080.00917.67
7.1.50.0070.00816.56
7.1.40.0040.00715.97
7.1.30.0040.00716.15
7.1.20.0080.00415.80
7.1.10.0040.00716.01
7.1.00.0050.03919.18
7.0.330.0070.00715.53
7.0.320.0030.00915.55
7.0.310.0050.00515.59
7.0.300.0000.01115.54
7.0.290.0030.00515.32
7.0.280.0040.01115.60
7.0.270.0030.00615.73
7.0.260.0030.01015.64
7.0.250.0060.00615.36
7.0.240.0070.00615.63
7.0.230.0030.00915.62
7.0.220.0100.00315.51
7.0.210.0070.00715.54
7.0.200.0070.00516.34
7.0.190.0030.00615.52
7.0.180.0080.00315.42
7.0.170.0030.01015.52
7.0.160.0030.00715.38
7.0.150.0030.00715.54
7.0.140.0030.04218.85
7.0.130.0000.01115.53
7.0.120.0030.03818.93
7.0.110.0120.00015.78
7.0.100.0100.00715.83
7.0.90.0050.00315.63
7.0.80.0060.00315.54
7.0.70.0000.01215.33
7.0.60.0030.04517.99
7.0.50.0050.04516.74
7.0.40.0080.03017.01
7.0.30.0170.04217.03
7.0.20.0160.02616.96
7.0.10.0180.04017.02
7.0.00.0080.04217.03
5.6.380.0090.00314.21
5.6.370.0070.00714.50
5.6.360.0030.00614.40
5.6.350.0080.00314.73
5.6.340.0030.01014.54
5.6.330.0040.00414.65
5.6.320.0040.01114.85
5.6.310.0040.00814.41
5.6.300.0040.01114.59
5.6.290.0120.00314.50
5.6.280.0070.03718.02
5.6.270.0090.00314.42
5.6.260.0030.01014.53
5.6.250.0060.00614.30
5.6.240.0000.00814.80
5.6.230.0100.00314.60
5.6.220.0070.00714.43
5.6.210.0100.04417.70
5.6.200.0080.03516.45
5.6.190.0080.03617.83
5.6.180.0180.02817.50
5.6.170.0130.02617.70
5.6.160.0050.03917.59
5.6.150.0030.03116.47
5.6.140.0050.04516.49
5.6.130.0060.02316.71
5.6.120.0000.02817.77
5.6.110.0070.04718.01
5.6.100.0050.03617.82
5.6.90.0050.02517.88
5.6.80.0080.04517.55
5.6.70.2090.02217.54
5.6.60.0000.01314.23
5.6.50.0060.00914.38
5.6.40.0040.01114.61
5.6.30.0090.00914.36
5.6.20.0070.00714.34
5.6.10.0030.01014.46
5.6.00.0000.01114.44
5.5.380.0030.00311.47
5.5.370.0000.00611.68
5.5.360.0000.00611.13
5.5.350.0150.04115.89
5.5.340.0080.02714.70
5.5.330.0060.02815.89
5.5.320.0080.03715.97
5.5.310.0130.03015.82
5.5.300.0070.03314.78
5.5.290.0060.02014.66
5.5.280.0080.03816.21
5.5.270.0030.04516.11
5.5.260.0130.03316.21
5.5.250.0100.04016.08
5.5.240.0050.04715.87
5.5.230.0050.00311.40
5.5.220.0030.00911.22
5.5.210.0050.00511.28
5.5.200.0060.00011.07
5.5.190.0100.00011.46
5.5.180.0030.00610.89
5.5.170.0000.00811.17
5.5.160.0060.00610.86
5.5.150.0070.00411.23
5.5.140.0030.00711.38
5.5.130.0080.00411.45
5.5.120.0000.00711.12
5.5.110.0000.00611.04
5.5.100.0000.01011.41
5.5.90.0110.00011.01
5.5.80.0060.00311.46
5.5.70.0030.00311.27
5.5.60.0030.01011.30
5.5.50.0030.00711.34
5.5.40.0080.00411.13
5.5.30.0050.00511.20
5.5.20.0030.00611.29
5.5.10.0040.00711.29
5.5.00.0030.00311.02
5.4.450.0080.03015.37
5.4.440.0090.02215.37
5.4.430.0070.04315.51
5.4.420.0050.02715.44
5.4.410.0040.02215.31
5.4.400.0080.02015.33
5.4.390.0060.04415.00
5.4.380.0030.04514.96
5.4.370.0030.02715.32
5.4.360.0110.03015.14
5.4.350.0070.04015.15
5.4.340.0100.02515.10
5.4.330.0060.00611.15
5.4.320.0010.03915.31
5.4.310.0070.02815.37
5.4.300.0080.02815.03
5.4.290.0100.03815.29
5.4.280.0060.03714.98
5.4.270.0120.02515.04
5.4.260.0080.03815.27
5.4.250.0090.03215.31
5.4.240.0030.04515.08
5.4.230.0050.02915.07
5.4.220.0070.03715.12
5.4.210.0080.02915.41
5.4.200.0050.04015.13
5.4.190.0100.03415.32
5.4.180.0090.02315.19
5.4.170.0080.02615.18
5.4.160.0030.04215.21
5.4.150.0040.02815.36
5.4.140.0020.02413.85
5.4.130.0040.02513.76
5.4.120.0070.03513.78
5.4.110.0080.03713.81
5.4.100.0060.02113.89
5.4.90.0020.02713.91
5.4.80.0050.04313.95
5.4.70.0100.03513.96
5.4.60.0020.02813.94
5.4.50.0070.03913.93
5.4.40.0110.03613.78
5.4.30.0030.03713.85
5.4.20.0070.02213.84
5.4.10.0050.02013.74
5.4.00.0060.02013.61
5.3.290.0000.04612.81
5.3.280.0020.02612.75
5.3.270.0120.03412.85
5.3.260.0030.02812.84
5.3.250.0090.03812.71
5.3.240.0070.02812.83
5.3.230.0050.02712.92
5.3.220.0040.04012.68
5.3.210.0100.03912.75
5.3.200.0020.03412.58
5.3.190.0020.02712.69
5.3.180.0040.02912.74
5.3.170.0030.03912.81
5.3.160.0070.02712.73
5.3.150.0080.02212.71
5.3.140.0040.03212.86
5.3.130.0030.02612.59
5.3.120.0060.04012.76
5.3.110.0050.04212.75
5.3.100.0070.01812.49
5.3.90.0020.02212.47
5.3.80.0030.02112.40
5.3.70.0020.02412.50
5.3.60.0040.01812.42
5.3.50.0030.02212.44
5.3.40.0040.01912.34
5.3.30.0020.02112.46
5.3.20.0040.01912.32
5.3.10.0020.02012.15
5.3.00.0020.02312.12
5.2.170.0010.01610.66
5.2.160.0040.01510.71
5.2.150.0020.01810.68
5.2.140.0040.01710.72
5.2.130.0030.01510.68
5.2.120.0030.02010.60
5.2.110.0030.01610.60
5.2.100.0030.01710.63
5.2.90.0020.01710.65
5.2.80.0030.01610.65
5.2.70.0020.01710.65
5.2.60.0020.01710.62
5.2.50.0070.01210.65
5.2.40.0030.01710.59
5.2.30.0020.01710.54
5.2.20.0070.01210.57
5.2.10.0070.01310.53
5.2.00.0100.01010.41
5.1.60.0030.01310.04
5.1.50.0040.01410.09
5.1.40.0020.01710.12
5.1.30.0020.01510.29
5.1.20.0030.01510.30
5.1.10.0030.01310.05
5.1.00.0010.01510.04
5.0.50.0020.0109.33
5.0.40.0030.0109.33
5.0.30.0030.0169.33
5.0.20.0030.0109.33
5.0.10.0000.0149.33
5.0.00.0020.0179.33
4.4.90.0050.0069.33
4.4.80.0000.0129.33
4.4.70.0030.0079.33
4.4.60.0020.0089.33
4.4.50.0000.0089.33
4.4.40.0000.0149.33
4.4.30.0020.0109.33
4.4.20.0000.0129.33
4.4.10.0040.0079.33
4.4.00.0010.0139.33
4.3.110.0000.0109.33
4.3.100.0020.0089.33
4.3.90.0020.0109.33
4.3.80.0000.0149.33
4.3.70.0030.0089.33
4.3.60.0000.0119.33
4.3.50.0030.0109.33
4.3.40.0030.0179.33
4.3.30.0000.0129.33
4.3.20.0020.0079.33
4.3.10.0020.0089.33
4.3.00.0000.0099.33

preferences:
45.03 ms | 401 KiB | 5 Q