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((array) $this->xml->$offset); return (array) $this->xml->$offset;//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.0140.00718.93
8.3.50.0130.00921.26
8.3.40.0090.00619.27
8.3.30.0130.00318.98
8.3.20.0000.00819.02
8.3.10.0040.00419.54
8.3.00.0040.00423.77
8.2.180.0110.00317.00
8.2.170.0120.00322.96
8.2.160.0080.00520.65
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0050.00320.02
8.2.110.0070.01020.60
8.2.100.0080.00318.16
8.2.90.0050.00319.36
8.2.80.0050.00318.18
8.2.70.0030.00617.88
8.2.60.0060.00618.15
8.2.50.0000.00818.07
8.2.40.0050.00318.41
8.2.30.0040.00421.26
8.2.20.0070.00017.85
8.2.10.0060.00318.00
8.2.00.0040.00417.98
8.1.280.0110.01125.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0100.00028.09
8.1.240.0040.00422.54
8.1.230.0070.00421.14
8.1.220.0090.00018.77
8.1.210.0000.00819.03
8.1.200.0030.00617.60
8.1.190.0040.00417.89
8.1.180.0040.00418.10
8.1.170.0060.00318.95
8.1.160.0040.00419.15
8.1.150.0040.00418.84
8.1.140.0000.00817.59
8.1.130.0070.00018.13
8.1.120.0070.00017.75
8.1.110.0040.00417.62
8.1.100.0000.00717.73
8.1.90.0000.00717.71
8.1.80.0040.00417.62
8.1.70.0030.00317.60
8.1.60.0060.00617.86
8.1.50.0040.00417.64
8.1.40.0030.00617.79
8.1.30.0030.00517.84
8.1.20.0040.00417.74
8.1.10.0050.00317.86
8.1.00.0000.00817.76
8.0.300.0000.00720.12
8.0.290.0000.00717.30
8.0.280.0000.00718.72
8.0.270.0040.00417.56
8.0.260.0060.00018.71
8.0.250.0080.00017.29
8.0.240.0040.00417.16
8.0.230.0030.00317.13
8.0.220.0000.00817.25
8.0.210.0030.00317.11
8.0.200.0000.00617.13
8.0.190.0060.00317.17
8.0.180.0000.00717.06
8.0.170.0080.00317.10
8.0.160.0000.00817.18
8.0.150.0040.00417.13
8.0.140.0050.00317.06
8.0.130.0000.00613.64
8.0.120.0000.00817.17
8.0.110.0000.00817.23
8.0.100.0000.00717.10
8.0.90.0040.00417.10
8.0.80.0030.01317.22
8.0.70.0000.00717.02
8.0.60.0040.00417.14
8.0.50.0040.00417.03
8.0.30.0120.01017.34
8.0.20.0200.01117.46
8.0.10.0040.00417.14
8.0.00.0140.00617.07
7.4.330.0030.00314.82
7.4.320.0030.00316.79
7.4.300.0000.00616.83
7.4.290.0040.00416.79
7.4.280.0000.00816.82
7.4.270.0070.00016.68
7.4.260.0000.00513.57
7.4.250.0080.00016.77
7.4.240.0070.00016.86
7.4.230.0070.00016.66
7.4.220.0120.00616.82
7.4.210.0130.00416.88
7.4.200.0000.00716.86
7.4.190.0070.00016.77
7.4.160.0100.01016.64
7.4.150.0040.01317.40
7.4.140.0150.00517.86
7.4.130.0130.00616.84
7.4.120.0100.00716.81
7.4.110.0030.01417.02
7.4.100.0150.00316.72
7.4.90.0200.00316.63
7.4.80.0030.01419.39
7.4.70.0130.00616.82
7.4.60.0030.01316.89
7.4.50.0030.00616.96
7.4.40.0070.01122.52
7.4.30.0100.01316.69
7.4.00.0040.00814.97
7.3.330.0000.00513.64
7.3.320.0000.00513.63
7.3.310.0000.00716.50
7.3.300.0040.00416.48
7.3.290.0110.00316.61
7.3.280.0070.01116.62
7.3.270.0100.01017.40
7.3.260.0060.01318.24
7.3.250.0050.01216.74
7.3.240.0110.00916.74
7.3.230.0140.00316.71
7.3.210.0070.01016.74
7.3.200.0110.01119.39
7.3.190.0170.00716.56
7.3.180.0090.00716.69
7.3.170.0110.00616.88
7.3.160.0060.00916.76
7.3.120.0070.01015.04
7.3.10.0110.00716.37
7.3.00.0140.00316.19
7.2.330.0120.00616.75
7.2.320.0120.01217.05
7.2.310.0130.00716.80
7.2.300.0050.01117.14
7.2.290.0090.01717.14
7.2.130.0090.00916.70
7.2.120.0210.00316.43
7.2.110.0090.00916.45
7.2.100.0110.01116.54
7.2.90.0100.01616.73
7.2.80.0150.00316.68
7.2.70.0090.01616.96
7.2.60.0100.01216.67
7.2.50.0160.01016.50
7.2.40.0220.00416.56
7.2.30.0310.00016.63
7.2.20.0180.00416.46
7.2.10.0070.01616.30
7.2.00.0080.01118.05
7.1.250.0060.01215.45
7.1.200.0080.00315.77
7.1.100.0000.01518.41
7.1.70.0000.01116.96
7.1.60.0040.02119.40
7.1.50.0130.01017.18
7.1.00.0000.05022.47
7.0.200.0040.00417.01
7.0.140.0030.07322.22
7.0.70.0100.07321.77
7.0.60.0000.08021.88
7.0.50.0070.06322.23
7.0.40.0000.06020.07
7.0.30.0030.04320.27
7.0.20.0000.04320.04
7.0.10.0000.04320.18
7.0.00.0000.04320.02
5.6.280.0070.07021.02
5.6.220.0070.07020.58
5.6.210.0000.08320.81
5.6.200.0100.08021.13
5.6.190.0030.04721.27
5.6.180.0030.04021.13
5.6.170.0100.03321.10
5.6.160.0000.03321.00
5.6.150.0130.03021.19
5.6.140.0000.04321.15
5.6.130.0000.05321.15
5.6.120.0070.03021.12
5.6.110.0000.03721.15
5.6.100.0030.04021.11
5.6.90.0030.04020.97
5.6.80.0000.04720.45
5.6.70.0000.03720.51
5.6.60.0000.04020.38
5.6.50.0030.04320.55
5.6.40.0000.03320.46
5.6.30.0070.02720.46
5.6.20.0030.03020.48
5.6.10.0070.02720.48
5.6.00.0030.03020.37
5.5.360.0130.05320.39
5.5.350.0130.06320.55
5.5.340.0100.07320.95
5.5.330.0000.05320.89
5.5.320.0030.04020.80
5.5.310.0070.03720.81
5.5.300.0030.03320.98
5.5.290.0000.04321.01
5.5.280.0030.04320.79
5.5.270.0000.03720.75
5.5.260.0030.03321.00
5.5.250.0000.03320.75
5.5.240.0030.03020.37
5.5.230.0000.03320.38
5.5.220.0030.03720.14
5.5.210.0070.03020.43
5.5.200.0000.03320.10
5.5.190.0000.03320.21
5.5.180.0000.03320.14
5.5.160.0030.03320.27
5.5.150.0030.03720.39
5.5.140.0030.03020.29
5.5.130.0000.03320.30
5.5.120.0000.03320.11
5.5.110.0030.03020.11
5.5.100.0000.03320.11
5.5.90.0000.03320.13
5.5.80.0070.02720.03
5.5.70.0030.03320.23
5.5.60.0000.07720.21
5.5.50.0030.07720.22
5.5.40.0070.06320.27
5.5.30.0070.07720.22
5.5.20.0030.08320.12
5.5.10.0030.08720.24
5.5.00.0030.06320.20
5.4.450.0030.04019.56
5.4.440.0030.04319.27
5.4.430.0030.03019.66
5.4.420.0000.03319.49
5.4.410.0070.02719.29
5.4.400.0030.03319.09
5.4.390.0000.06018.94
5.4.380.0000.05019.16
5.4.370.0030.05019.25
5.4.360.0030.03019.25
5.4.350.0000.03019.10
5.4.340.0030.03019.24
5.4.320.0030.03019.22
5.4.310.0000.03319.08
5.4.300.0030.02719.00
5.4.290.0000.03019.25
5.4.280.0000.04019.28
5.4.270.0000.03018.93
5.4.260.0000.03019.25
5.4.250.0000.03719.21
5.4.240.0000.03319.24
5.4.230.0000.03018.99
5.4.220.0000.04319.21
5.4.210.0000.06719.33
5.4.200.0130.07019.20
5.4.190.0000.06019.08
5.4.180.0000.08318.98
5.4.170.0000.08019.21
5.4.160.0030.07019.32
5.4.150.0030.07719.18
5.4.140.0000.06016.49
5.4.130.0070.05716.56
5.4.120.0030.03316.48
5.4.110.0000.03716.58
5.4.100.0000.04716.56
5.4.90.0070.07016.63
5.4.80.0070.07016.59
5.4.70.0070.06016.48
5.4.60.0030.07316.43
5.4.50.0000.07716.57
5.4.40.0030.07016.56
5.4.30.0000.07316.47
5.4.20.0070.07716.52
5.4.10.0030.07016.48
5.4.00.0030.07316.01
5.3.290.0030.03014.85
5.3.280.0000.06014.73
5.3.270.0070.06714.89
5.3.260.0070.07714.74
5.3.250.0070.06714.79
5.3.240.0030.08014.62
5.3.230.0000.06014.73
5.3.220.0000.05314.65
5.3.210.0070.07314.58
5.3.200.0030.05314.63
5.3.190.0000.04714.65
5.3.180.0030.07014.72
5.3.170.0000.07714.58
5.3.160.0000.06314.64
5.3.150.0030.07314.71
5.3.140.0000.07314.79
5.3.130.0030.07314.70
5.3.120.0030.07314.63
5.3.110.0070.07714.61
5.3.100.0070.07014.29
5.3.90.0070.06714.10
5.3.80.0070.06714.16
5.3.70.0030.07314.25
5.3.60.0000.07714.27
5.3.50.0030.07714.13
5.3.40.0000.07713.98
5.3.30.0070.07314.17
5.3.20.0000.07013.82
5.3.10.0030.06013.74
5.3.00.0070.06713.91
5.2.170.0030.06711.28
5.2.160.0030.06011.36
5.2.150.0100.05311.29
5.2.140.0030.06011.39
5.2.130.0000.06711.33
5.2.120.0030.06011.32
5.2.110.0030.05711.09
5.2.100.0100.05711.18
5.2.90.0070.05711.34
5.2.80.0030.06311.35
5.2.70.0070.05711.32
5.2.60.0000.06311.20
5.2.50.0000.06311.10
5.2.40.0070.05311.22
5.2.30.0070.05711.15
5.2.20.0030.06311.14
5.2.10.0100.05711.12
5.2.00.0070.05710.90
5.1.60.0000.05010.32
5.1.50.0030.05310.32
5.1.40.0030.05010.32
5.1.30.0100.04710.52
5.1.20.0070.05010.39
5.1.10.0000.05710.32
5.1.00.0030.05710.32
5.0.50.0000.04710.32
5.0.40.0100.03010.32
5.0.30.0070.05710.32
5.0.20.0030.03710.32
5.0.10.0030.02710.32
5.0.00.0000.03710.32
4.4.90.0000.03710.32
4.4.80.0030.03310.32
4.4.70.0030.03310.32
4.4.60.0070.03010.32
4.4.50.0030.02310.32
4.4.40.0070.05010.32
4.4.30.0000.03710.32
4.4.20.0000.03710.32
4.4.10.0070.03010.32
4.4.00.0030.04710.32
4.3.110.0000.03710.32
4.3.100.0030.03010.32
4.3.90.0030.03310.32
4.3.80.0030.02010.32
4.3.70.0030.01010.32
4.3.60.0000.03010.32
4.3.50.0000.02310.32
4.3.40.0030.02710.32
4.3.30.0030.01710.32
4.3.20.0030.03010.32
4.3.10.0030.02710.32
4.3.00.0000.01710.32

preferences:
49.47 ms | 401 KiB | 5 Q