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($this->xml->$offset); return (array) $this->xml->$offset;//new self($this->xml->$offset->asXML(), false); } public function __toString() { return (string) ((array) $this->xml->$offset[0]); } 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.70.0120.00316.62
8.3.60.0000.01518.68
8.3.50.0140.00722.11
8.3.40.0090.00619.05
8.3.30.0060.00918.96
8.3.20.0000.00819.02
8.3.10.0050.00321.35
8.3.00.0040.00823.95
8.2.180.0160.00316.75
8.2.170.0180.00422.96
8.2.160.0070.00720.64
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0000.00821.17
8.2.110.0030.00620.69
8.2.100.0000.01218.09
8.2.90.0080.00019.65
8.2.80.0000.00917.97
8.2.70.0030.00617.88
8.2.60.0080.00018.29
8.2.50.0000.00818.07
8.2.40.0050.00318.28
8.2.30.0040.00421.43
8.2.20.0000.00717.86
8.2.10.0040.00417.92
8.2.00.0000.00818.12
8.1.280.0080.00825.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0060.00322.54
8.1.230.0110.00021.15
8.1.220.0040.00418.77
8.1.210.0050.00319.04
8.1.200.0060.00317.47
8.1.190.0000.00817.78
8.1.180.0040.00418.10
8.1.170.0030.00618.87
8.1.160.0030.00619.02
8.1.150.0000.00718.77
8.1.140.0080.00017.66
8.1.130.0000.00717.94
8.1.120.0070.00017.57
8.1.110.0040.00417.63
8.1.100.0040.00417.69
8.1.90.0000.00717.67
8.1.80.0090.00017.66
8.1.70.0040.00417.72
8.1.60.0000.00817.71
8.1.50.0030.00617.56
8.1.40.0000.00817.71
8.1.30.0080.00017.86
8.1.20.0040.00417.86
8.1.10.0030.00517.77
8.1.00.0040.00717.74
8.0.300.0070.00020.14
8.0.290.0080.00017.55
8.0.280.0080.00018.67
8.0.270.0070.00317.39
8.0.260.0040.00417.12
8.0.250.0040.00417.21
8.0.240.0000.00717.25
8.0.230.0000.00717.22
8.0.220.0030.00317.04
8.0.210.0040.00417.26
8.0.200.0030.00317.11
8.0.190.0050.00317.25
8.0.180.0000.00717.09
8.0.170.0030.00517.23
8.0.160.0080.00017.12
8.0.150.0000.00717.09
8.0.140.0000.00716.99
8.0.130.0000.00513.63
8.0.120.0040.00417.08
8.0.110.0040.00417.02
8.0.100.0040.00417.21
8.0.90.0000.00817.22
8.0.80.0130.00317.24
8.0.70.0030.00517.21
8.0.60.0040.00417.06
8.0.50.0080.00017.03
8.0.30.0150.00817.38
8.0.20.0060.01617.40
8.0.10.0040.00417.17
8.0.00.0080.01017.04
7.4.330.0050.00015.00
7.4.320.0030.00316.76
7.4.300.0000.00716.64
7.4.290.0040.00416.81
7.4.280.0030.00316.75
7.4.270.0080.00016.79
7.4.260.0000.00513.37
7.4.250.0040.00416.65
7.4.240.0050.00316.80
7.4.230.0070.00016.79
7.4.220.0080.00816.67
7.4.210.0070.00816.81
7.4.200.0040.00416.94
7.4.190.0070.00016.77
7.4.160.0080.00816.56
7.4.150.0060.01217.40
7.4.140.0100.00717.86
7.4.130.0070.01016.71
7.4.120.0090.00916.90
7.4.110.0120.00616.55
7.4.100.0090.01216.92
7.4.90.0110.01216.90
7.4.80.0120.00619.39
7.4.70.0060.01016.64
7.4.60.0130.00616.86
7.4.50.0030.00616.78
7.4.40.0060.00922.77
7.4.30.0090.00916.80
7.4.00.0070.01015.39
7.3.330.0030.00313.64
7.3.320.0020.00213.45
7.3.310.0080.00016.62
7.3.300.0000.00716.48
7.3.290.0090.00616.63
7.3.280.0080.00916.66
7.3.270.0040.01417.40
7.3.260.0090.01218.24
7.3.250.0100.00716.74
7.3.240.0090.00916.81
7.3.230.0060.01216.70
7.3.210.0120.00616.64
7.3.200.0080.01119.39
7.3.190.0170.00716.68
7.3.180.0160.00516.79
7.3.170.0070.01516.78
7.3.160.0090.00816.62
7.3.120.0000.01215.34
7.2.330.0030.01616.82
7.2.320.0190.00316.66
7.2.310.0100.00717.04
7.2.300.0110.01116.79
7.2.290.0130.00317.05
7.2.60.0060.00917.12
7.2.00.0060.00619.34
7.1.200.0120.00316.15
7.1.100.0030.01118.10
7.1.70.0090.00617.32
7.1.60.0100.01619.40
7.1.50.0110.00716.93
7.1.00.0000.06322.43
7.0.200.0080.00016.89
7.0.140.0030.07322.08
7.0.80.0530.07020.03
7.0.70.0300.03719.95
7.0.60.0430.07720.20
7.0.50.0430.05720.43
7.0.40.0100.03720.15
7.0.30.0070.03320.04
7.0.20.0070.07320.14
7.0.10.0100.06720.18
7.0.00.0100.08720.25
5.6.280.0000.07720.89
5.6.230.0100.06720.55
5.6.220.0100.06720.83
5.6.210.0070.03320.51
5.6.200.0030.04321.09
5.6.190.0070.04021.13
5.6.180.0070.07721.29
5.6.170.0030.03721.15
5.6.160.0030.07020.99
5.6.150.0070.03721.11
5.6.140.0070.05021.07
5.6.130.0030.04721.06
5.6.120.0030.04021.16
5.6.110.0070.07720.99
5.6.100.0100.08320.98
5.6.90.0070.09021.05
5.6.80.0100.07720.56
5.6.70.0000.04320.55
5.6.60.0030.04320.52
5.6.50.0030.04320.68
5.6.40.0030.08320.35
5.6.30.0030.04320.52
5.6.20.0000.03720.48
5.6.10.0070.03320.42
5.6.00.0030.03320.45
5.5.370.0070.03320.46
5.5.360.0030.03720.46
5.5.350.0030.03720.40
5.5.340.0070.07320.90
5.5.330.0000.04320.87
5.5.320.0130.03020.80
5.5.310.0070.08320.98
5.5.300.0070.03320.96
5.5.290.0000.04020.79
5.5.280.0170.06720.95
5.5.270.0130.04320.93
5.5.260.0030.09020.95
5.5.250.0130.08020.74
5.5.240.0130.03320.40
5.5.230.0100.07020.37
5.5.220.0100.05720.27
5.5.210.0070.04720.39
5.5.200.0030.08720.28
5.5.190.0030.03320.36
5.5.180.0070.03720.38
5.5.160.0070.03020.21
5.5.150.0170.05720.39
5.5.140.0070.06320.22
5.5.130.0030.06320.30
5.5.120.0070.08020.14
5.5.110.0000.04020.38
5.5.100.0000.03720.23
5.5.90.0030.04020.27
5.5.80.0070.03720.03
5.5.70.0030.07320.12
5.5.60.0030.07020.11
5.5.50.0030.04320.15
5.5.40.0030.04320.27
5.5.30.0030.07020.15
5.5.20.0030.04320.24
5.5.10.0070.06320.25
5.5.00.0070.04020.08
5.4.450.0070.05019.56
5.4.440.0070.04019.55
5.4.430.0000.03719.60
5.4.420.0070.04719.62
5.4.410.0100.05319.48
5.4.400.0030.03319.11
5.4.390.0000.03719.23
5.4.380.0070.07719.04
5.4.370.0070.03719.02
5.4.360.0100.06719.04
5.4.350.0000.03319.36
5.4.340.0070.03319.28
5.4.320.0030.03319.27
5.4.310.0000.04719.24
5.4.300.0100.04319.02
5.4.290.0100.03319.23
5.4.280.0000.03719.22
5.4.270.0030.03319.17
5.4.260.0100.06318.91
5.4.250.0070.04319.12
5.4.240.0130.07719.21
5.4.230.0030.05019.01
5.4.220.0030.03319.27
5.4.210.0130.06319.24
5.4.200.0030.04019.01
5.4.190.0070.03319.01
5.4.180.0100.08319.26
5.4.170.0100.07319.21
5.4.160.0030.08019.00
5.4.150.0030.03319.21
5.4.140.0070.06016.63
5.4.130.0030.04016.64
5.4.120.0000.07716.53
5.4.110.0070.03716.46
5.4.100.0100.04016.59
5.4.90.0030.04716.67
5.4.80.0030.05016.58
5.4.70.0000.03716.55
5.4.60.0000.08016.60
5.4.50.0030.03016.48
5.4.40.0100.07016.57
5.4.30.0030.07316.56
5.4.20.0100.02716.46
5.4.10.0030.03716.64
5.4.00.0070.07315.98
5.3.290.0070.06314.95
5.3.280.0100.03014.85
5.3.270.0070.05314.84
5.3.260.0100.05314.83
5.3.250.0070.05714.62
5.3.240.0100.07014.76
5.3.230.0030.06314.80
5.3.220.0070.03714.75
5.3.210.0070.07714.71
5.3.200.0030.05714.79
5.3.190.0070.06714.61
5.3.180.0030.03714.79
5.3.170.0100.04014.64
5.3.160.0070.07014.71
5.3.150.0030.04714.60
5.3.140.0070.05714.79
5.3.130.0000.04714.73
5.3.120.0000.04014.78
5.3.110.0000.04014.59
5.3.100.0030.03314.19
5.3.90.0030.03014.20
5.3.80.0070.02714.16
5.3.70.0030.03014.16
5.3.60.0000.04014.00
5.3.50.0030.03713.95
5.3.40.0030.07014.03
5.3.30.0030.03014.09
5.3.20.0000.08013.82
5.3.10.0070.06313.78
5.3.00.0000.03313.63
5.2.170.0070.04012.34
5.2.160.0070.05012.34
5.2.150.0070.05712.34
5.2.140.0000.02712.34
5.2.130.0030.04312.34
5.2.120.0070.02712.34
5.2.110.0000.02712.34
5.2.100.0030.02312.34
5.2.90.0000.02712.34
5.2.80.0070.02712.34
5.2.70.0000.02712.34
5.2.60.0030.03012.34
5.2.50.0130.06312.34
5.2.40.0070.03312.34
5.2.30.0030.03312.34
5.2.20.0030.02312.34
5.2.10.0000.03012.34
5.2.00.0000.03712.34
5.1.60.0000.02712.34
5.1.50.0000.03312.34
5.1.40.0070.02712.34
5.1.30.0030.02712.34
5.1.20.0000.03012.34
5.1.10.0070.02012.34
5.1.00.0030.03712.34
5.0.50.0000.03712.34
5.0.40.0000.02312.34
5.0.30.0000.04712.34
5.0.20.0000.04712.34
5.0.10.0030.03712.34
5.0.00.0070.07012.34
4.4.90.0000.01312.34
4.4.80.0000.01712.34
4.4.70.0030.01312.34
4.4.60.0030.01712.34
4.4.50.0000.02312.34
4.4.40.0000.05312.34
4.4.30.0000.01712.34
4.4.20.0030.02012.34
4.4.10.0000.03712.34
4.4.00.0000.03712.34
4.3.110.0030.03312.34
4.3.100.0000.01712.34
4.3.90.0030.03312.34
4.3.80.0000.02712.34
4.3.70.0000.01712.34
4.3.60.0000.01712.34
4.3.50.0000.01712.34
4.3.40.0000.02012.34
4.3.30.0000.01312.34
4.3.20.0000.03312.34
4.3.10.0030.02012.34
4.3.00.0000.01712.34

preferences:
41.33 ms | 401 KiB | 5 Q