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() { if (count($this->xml) > 1) { return (string) $this->xml[0]; } 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.0110.00716.75
8.3.50.0080.00822.04
8.3.40.0180.00419.24
8.3.30.0070.00719.38
8.3.20.0080.00020.49
8.3.10.0080.00023.73
8.3.00.0080.00019.50
8.2.180.0130.00318.79
8.2.170.0070.00722.96
8.2.160.0060.00820.47
8.2.150.0030.00524.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0000.00822.24
8.2.110.0110.00019.46
8.2.100.0060.00618.23
8.2.90.0030.00619.47
8.2.80.0000.00817.97
8.2.70.0060.00317.88
8.2.60.0040.00418.05
8.2.50.0030.00618.07
8.2.40.0070.00019.50
8.2.30.0050.00518.38
8.2.20.0040.00417.84
8.2.10.0050.00218.32
8.2.00.0070.00017.83
8.1.280.0120.00325.92
8.1.270.0030.01324.08
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0090.00319.46
8.1.230.0060.00617.70
8.1.220.0040.00417.90
8.1.210.0040.00418.77
8.1.200.0030.00717.63
8.1.190.0040.00417.48
8.1.180.0000.00818.10
8.1.170.0050.00518.89
8.1.160.0000.00722.23
8.1.150.0000.00818.79
8.1.140.0020.00517.65
8.1.130.0030.00318.00
8.1.120.0000.00717.59
8.1.110.0050.00317.64
8.1.100.0040.00417.66
8.1.90.0040.00417.68
8.1.80.0070.00017.67
8.1.70.0000.00717.60
8.1.60.0030.00617.86
8.1.50.0030.00617.73
8.1.40.0050.00317.67
8.1.30.0040.00417.81
8.1.20.0030.00617.95
8.1.10.0000.00717.73
8.1.00.0000.00917.77
8.0.300.0020.00518.77
8.0.290.0040.00417.00
8.0.280.0000.00718.57
8.0.270.0030.00317.45
8.0.260.0000.00617.18
8.0.250.0070.00017.11
8.0.240.0000.00717.29
8.0.230.0070.00017.13
8.0.220.0030.00317.05
8.0.210.0000.00717.17
8.0.200.0000.00717.26
8.0.190.0040.00417.16
8.0.180.0080.00017.24
8.0.170.0040.00417.14
8.0.160.0000.00717.13
8.0.150.0050.00317.13
8.0.140.0000.00717.12
8.0.130.0050.00213.68
8.0.120.0050.00317.06
8.0.110.0080.00017.11
8.0.100.0000.00717.00
8.0.90.0040.00417.11
8.0.80.0070.01417.18
8.0.70.0040.00417.21
8.0.60.0000.00817.32
8.0.50.0040.00417.16
8.0.30.0140.00817.47
8.0.20.0090.01117.51
8.0.10.0050.00217.16
8.0.00.0090.00916.84
7.4.330.0050.00015.23
7.4.320.0000.00616.80
7.4.300.0000.00716.82
7.4.290.0040.00416.73
7.4.280.0040.00416.66
7.4.270.0030.00316.80
7.4.260.0000.00716.82
7.4.250.0060.00316.60
7.4.240.0060.00116.75
7.4.230.0000.00716.84
7.4.220.0120.00916.67
7.4.210.0070.00916.80
7.4.200.0030.00316.64
7.4.190.0070.00017.02
7.4.160.0070.01816.76
7.4.150.0130.00917.40
7.4.140.0100.00917.86
7.4.130.0110.00816.68
7.4.120.0090.00716.70
7.4.110.0130.00316.64
7.4.100.0150.00616.70
7.4.90.0070.01116.84
7.4.80.0100.01019.39
7.4.70.0070.01016.90
7.4.60.0100.00717.04
7.4.50.0050.00516.82
7.4.40.0090.00622.77
7.4.30.0160.00016.73
7.4.10.0100.00715.04
7.4.00.0050.01115.20
7.3.330.0000.00813.52
7.3.320.0070.00013.40
7.3.310.0080.00016.71
7.3.300.0040.00416.62
7.3.290.0110.00716.64
7.3.280.0080.01116.67
7.3.270.0160.00617.40
7.3.260.0080.01116.65
7.3.250.0110.00816.74
7.3.240.0030.01516.85
7.3.230.0100.00616.55
7.3.210.0130.01016.71
7.3.200.0150.00819.39
7.3.190.0130.01016.64
7.3.180.0080.00816.78
7.3.170.0090.00616.80
7.3.160.0090.00916.78
7.3.130.0100.00715.28
7.3.120.0070.01014.96
7.3.110.0080.01115.05
7.3.100.0080.00815.23
7.3.90.0030.00915.23
7.3.80.0070.00315.16
7.3.70.0040.01215.02
7.3.60.0030.00914.87
7.3.50.0100.00015.29
7.3.40.0070.00714.95
7.3.30.0090.00315.05
7.3.20.0080.00817.00
7.3.10.0140.00316.79
7.3.00.0040.01216.88
7.2.330.0070.01016.97
7.2.320.0130.00616.79
7.2.310.0100.00717.10
7.2.300.0000.01716.96
7.2.290.0090.00816.97
7.2.260.0060.01014.95
7.2.250.0070.01115.36
7.2.240.0030.00915.09
7.2.230.0070.01115.12
7.2.220.0090.00614.93
7.2.210.0000.01315.00
7.2.200.0000.01415.29
7.2.190.0070.00715.06
7.2.180.0030.01315.31
7.2.170.0080.00415.24
7.2.160.0060.00615.06
7.2.150.0060.00917.03
7.2.140.0090.00617.10
7.2.130.0070.01017.16
7.2.120.0070.01117.07
7.2.110.0100.00716.97
7.2.100.0130.00616.78
7.2.90.0070.01017.14
7.2.80.0130.00317.10
7.2.70.0000.01417.20
7.2.60.0070.00717.10
7.2.50.0100.00617.25
7.2.40.0030.01317.06
7.2.30.0000.01917.05
7.2.20.0020.01317.17
7.2.10.0070.00417.07
7.2.00.0090.01118.12
7.1.330.0070.00715.93
7.1.320.0100.00716.09
7.1.310.0060.00615.92
7.1.300.0060.00915.96
7.1.290.0100.00315.92
7.1.280.0100.00315.87
7.1.270.0040.01115.82
7.1.260.0000.01315.96
7.1.250.0040.01116.00
7.1.240.0060.00915.68
7.1.230.0120.00316.10
7.1.220.0100.00615.95
7.1.210.0070.00715.97
7.1.200.0100.00316.07
7.1.190.0070.00715.84
7.1.180.0040.01115.99
7.1.170.0060.00915.84
7.1.160.0040.00715.98
7.1.150.0030.01016.04
7.1.140.0060.00915.90
7.1.130.0030.01215.65
7.1.120.0030.01016.01
7.1.110.0070.01015.84
7.1.100.0060.00817.03
7.1.90.0050.00816.17
7.1.80.0040.01115.86
7.1.70.0060.00616.79
7.1.60.0040.01217.67
7.1.50.0090.00516.55
7.1.40.0100.00315.59
7.1.30.0090.00615.89
7.1.20.0060.01216.01
7.1.10.0070.01115.91
7.1.00.0030.04419.21
7.0.330.0120.01215.70
7.0.320.0170.00715.73
7.0.310.0110.01415.66
7.0.300.0120.01215.53
7.0.290.0160.00615.35
7.0.280.0170.00915.49
7.0.270.0160.00415.57
7.0.260.0110.01315.42
7.0.250.0100.01515.84
7.0.240.0140.01115.63
7.0.230.0170.01015.82
7.0.220.0130.01315.43
7.0.210.0100.01515.50
7.0.200.0100.01016.19
7.0.190.0220.00315.50
7.0.180.0190.00615.68
7.0.170.0190.00615.66
7.0.160.0150.01015.54
7.0.150.0130.01515.68
7.0.140.0090.04218.92
7.0.130.0230.00015.58
7.0.120.0180.00815.74
7.0.110.0160.00715.70
7.0.100.0170.00715.39
7.0.90.0190.00515.46
7.0.80.0160.00615.47
7.0.70.0100.00915.45
7.0.60.0130.04517.81
7.0.50.0130.03216.70
7.0.40.0070.03416.83
7.0.30.0200.03716.96
7.0.20.0240.03616.93
7.0.10.0100.04916.87
7.0.00.0120.04716.90
5.6.400.0200.00314.63
5.6.390.0180.01114.77
5.6.380.0140.01114.55
5.6.370.0180.00414.46
5.6.360.0080.01614.79
5.6.350.0140.01014.86
5.6.340.0210.00914.70
5.6.330.0130.01614.66
5.6.320.0070.02214.48
5.6.310.0240.00314.32
5.6.300.0180.00914.43
5.6.290.0130.01614.45
5.6.280.0050.04617.73
5.6.270.0210.00614.56
5.6.260.0150.01114.56
5.6.250.0230.00414.63
5.6.240.0150.01214.77
5.6.230.0160.01214.41
5.6.220.0220.00514.87
5.6.210.0130.03917.54
5.6.200.0110.02916.49
5.6.190.0160.04417.46
5.6.180.0200.04817.67
5.6.170.0160.02717.50
5.6.160.0120.04817.54
5.6.150.0130.04616.36
5.6.140.0050.05116.57
5.6.130.0130.02416.50
5.6.120.0130.04217.79
5.6.110.0080.02417.84
5.6.100.0140.03817.81
5.6.90.0110.02417.63
5.6.80.0100.04617.48
5.6.70.0140.01414.41
5.6.60.0150.01214.55
5.6.50.0150.01214.42
5.6.40.0140.01414.52
5.6.30.0190.00714.32
5.6.20.0110.01514.40
5.6.10.0250.00414.34
5.6.00.0160.00814.84
5.5.380.0110.01414.21
5.5.370.0090.01814.39
5.5.360.0120.01514.32
5.5.350.0100.04417.48
5.5.340.0120.04716.45
5.5.330.0080.03217.29
5.5.320.0200.03217.51
5.5.310.0230.04417.57
5.5.300.0150.03516.30
5.5.290.0090.04616.46
5.5.280.0130.02817.64
5.5.270.0060.05217.83
5.5.260.0070.02717.62
5.5.250.0110.02417.38
5.5.240.2230.02317.30
5.5.230.0040.02314.21
5.5.220.0120.01214.22
5.5.210.0130.01314.63
5.5.200.0150.01114.49
5.5.190.0160.00814.62
5.5.180.0080.01714.61
5.5.170.0110.01414.51
5.5.160.0150.00814.20
5.5.150.0140.00614.35
5.5.140.0130.01314.35
5.5.130.0190.00614.52
5.5.120.0150.00414.59
5.5.110.0130.00814.21
5.5.100.0180.00714.34
5.5.90.0150.00914.43
5.5.80.0130.01314.37
5.5.70.0140.01114.22
5.5.60.0110.01014.34
5.5.50.0190.00414.34
5.5.40.0110.01114.18
5.5.30.0090.01814.57
5.5.20.0110.01314.55
5.5.10.0090.01314.67
5.5.00.0120.01214.08
5.4.450.0630.02515.48
5.4.440.0580.03315.49
5.4.430.0520.03615.25
5.4.420.0520.03915.43
5.4.410.0430.03415.26
5.4.400.0520.02915.27
5.4.390.0520.03115.18
5.4.380.0150.03414.89
5.4.370.0180.02814.87
5.4.360.0150.03214.91
5.4.350.0140.03415.13
5.4.340.0170.02915.13
5.4.330.0090.00611.21
5.4.320.0060.02211.87
5.4.310.0070.02811.90
5.4.300.0050.02611.97
5.4.290.0050.02611.96
5.4.280.0080.02511.94
5.4.270.0060.02311.94
5.4.260.0100.01811.87
5.4.250.0090.02911.92
5.4.240.0080.02711.77
5.4.230.0070.02811.78
5.4.220.0090.02111.90
5.4.210.0050.02611.99
5.4.200.0100.02311.86
5.4.190.0140.02511.76
5.4.180.0120.02611.87
5.4.170.0150.02211.88
5.4.160.0090.02911.85
5.4.150.0120.02711.89
5.4.140.0120.02611.80
5.4.130.0150.02311.64
5.4.120.0150.02111.60
5.4.110.0120.02611.70
5.4.100.0150.02311.75
5.4.90.0110.02811.67
5.4.80.0160.02211.78
5.4.70.0170.02011.59
5.4.60.0130.02511.61
5.4.50.0160.02211.61
5.4.40.0120.02411.63
5.4.30.0110.02611.77
5.4.20.0080.02811.78
5.4.10.0130.02311.69
5.4.00.0190.04911.51
5.3.290.0090.02411.77
5.3.280.0060.02611.76
5.3.270.0130.02511.83
5.3.260.0170.02211.85
5.3.250.0200.04811.78
5.3.240.0120.02511.72
5.3.230.0140.02511.81
5.3.220.0130.02611.77
5.3.210.0110.02811.68
5.3.200.0170.03711.76
5.3.190.0140.02411.71
5.3.180.0140.02511.86
5.3.170.0100.02811.76
5.3.160.0160.02411.87
5.3.150.0130.02511.78
5.3.140.0160.03811.82
5.3.130.0140.02611.79
5.3.120.0150.02611.62
5.3.110.0170.02211.73
5.3.100.0230.04811.36
5.3.90.0150.02311.49
5.3.80.0120.02811.40
5.3.70.0100.02811.43
5.3.60.0120.02611.35
5.3.50.0130.02311.32
5.3.40.0140.02311.41
5.3.30.0150.02011.47
5.3.20.0120.02611.31
5.3.10.0130.02311.20
5.3.00.0140.02311.22
5.2.170.0160.0329.38
5.2.160.0130.0359.38
5.2.150.0330.0779.38
5.2.140.0130.0369.37
5.2.130.0130.0349.33
5.2.120.0080.0389.34
5.2.110.0140.0349.34
5.2.100.0140.0359.34
5.2.90.0140.0339.34
5.2.80.0090.0399.33
5.2.70.0140.0389.33
5.2.60.0140.0349.28
5.2.50.0150.0329.25
5.2.40.0140.0369.23
5.2.30.0160.0329.20
5.2.20.0100.0379.20
5.2.10.0150.0319.10
5.2.00.0170.0298.96
5.1.60.0110.0338.25
5.1.50.0370.0678.25
5.1.40.0080.0338.24
5.1.30.0110.0328.59
5.1.20.0150.0288.60
5.1.10.0080.0378.17
5.1.00.0100.0318.17
5.0.50.0040.0306.65
5.0.40.0070.0246.51
5.0.30.0150.0316.33
5.0.20.0100.0236.30
5.0.10.0090.0226.27
5.0.00.0110.0346.26
4.4.90.0090.0164.77
4.4.80.0110.0144.75
4.4.70.0060.0194.76
4.4.60.0080.0174.75
4.4.50.0080.0174.77
4.4.40.0080.0574.71
4.4.30.0040.0214.75
4.4.20.0100.0154.85
4.4.10.0110.0194.85
4.4.00.0070.0284.76
4.3.110.0050.0194.67
4.3.100.0090.0154.67
4.3.90.0070.0174.64
4.3.80.0080.0264.58
4.3.70.0260.0584.63
4.3.60.0060.0184.63
4.3.50.0040.0204.62
4.3.40.0050.0284.54
4.3.30.0060.0173.30
4.3.20.0030.0203.27
4.3.10.0120.0413.24
4.3.00.0000.01315.59

preferences:
37.92 ms | 401 KiB | 5 Q