3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ArrayAccessAdapter; use ArrayAccess; use IteratorAggregate; use SimpleXmlIterator; use RuntimeException; class XmlArrayAccess implements ArrayAccess, IteratorAggregate { const ATTRIBUTE_PREFIX = '@'; private $xml; public function __construct(SimpleXmlIterator $xml) { $this->xml = $xml; } private function getElement($offset) { $isAttribute = false; if (substr($offset, 0, 1) == self::ATTRIBUTE_PREFIX) { $offset = substr($offset, 1); $isAttribute = false; } if (false !== $this->xml->$offset->asXML() && !$isAttribute) { $xml = $this->xml->$offset; } else { $xml = $this->xml[$offset]; } return $xml; } public function offsetExists($offset) { return !is_null($this->getElement($offset)); } public function offsetGet($offset) { if ($this->xml->getName() == $offset) { return $this; } $xml = $this->getElement($offset); if (is_null($xml)) { throw new RuntimeException('unknown node or attribute "' . $offset . '"'); } return new self($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; } public function __toString() { return (string) $this->xml; } } $xml = '<?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading foo="bar">Reminder</heading> <body>Don\'t forget me this weekend!</body> <recursive> <val>2</val> <val>4</val> </recursive> </note>'; $simple = new SimpleXmlIterator($xml); $xml = new XmlArrayAccess($simple); echo $xml['note']['to'][0]; echo $xml['note']['recursive']['val'][1]; echo $xml['note']['heading']['@foo']; echo $xml['note']['heading']['foo'];

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.0110.01118.43
8.3.60.0150.00618.65
8.3.50.0110.00822.18
8.3.40.0040.01419.22
8.3.30.0040.01119.17
8.3.20.0030.00619.20
8.3.10.0040.00421.42
8.3.00.0050.00323.91
8.2.180.0110.00417.00
8.2.170.0070.00719.34
8.2.160.0030.01022.96
8.2.150.0000.00824.18
8.2.140.0070.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00421.36
8.2.110.0000.00920.75
8.2.100.0110.00318.09
8.2.90.0000.00819.42
8.2.80.0050.00318.28
8.2.70.0040.00417.88
8.2.60.0060.00318.18
8.2.50.0000.00818.07
8.2.40.0030.00618.41
8.2.30.0000.00721.47
8.2.20.0000.00717.93
8.2.10.0030.00618.02
8.2.00.0040.00418.07
8.1.280.0090.00925.92
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00322.81
8.1.230.0000.01121.15
8.1.220.0000.00818.77
8.1.210.0040.00419.23
8.1.200.0000.01017.63
8.1.190.0040.00417.90
8.1.180.0040.00418.10
8.1.170.0060.00318.87
8.1.160.0030.00519.18
8.1.150.0000.00818.90
8.1.140.0040.00417.73
8.1.130.0000.00718.21
8.1.120.0070.00017.65
8.1.110.0000.00717.66
8.1.100.0050.00317.67
8.1.90.0040.00417.78
8.1.80.0050.00317.85
8.1.70.0030.00317.74
8.1.60.0080.00017.75
8.1.50.0030.00617.77
8.1.40.0030.00617.69
8.1.30.0000.00817.86
8.1.20.0000.00817.84
8.1.10.0050.00217.81
8.1.00.0080.00017.85
8.0.300.0040.00420.46
8.0.290.0040.00417.43
8.0.280.0050.00218.77
8.0.270.0070.00317.52
8.0.260.0000.00717.10
8.0.250.0040.00417.17
8.0.240.0060.00317.20
8.0.230.0040.00417.34
8.0.220.0030.00317.29
8.0.210.0000.00717.27
8.0.200.0050.00317.27
8.0.190.0040.00417.32
8.0.180.0040.00417.31
8.0.170.0000.00817.20
8.0.160.0040.00417.19
8.0.150.0020.00517.11
8.0.140.0040.00417.22
8.0.130.0000.00613.75
8.0.120.0000.00917.24
8.0.110.0050.00217.34
8.0.100.0030.00517.36
8.0.90.0040.00417.18
8.0.80.0060.00917.38
8.0.70.0060.00317.17
8.0.60.0040.00417.18
8.0.50.0040.00417.30
8.0.30.0080.01317.35
8.0.20.0030.01917.53
8.0.10.0040.00417.23
8.0.00.0090.00917.08
7.4.330.0000.00514.98
7.4.320.0030.00916.91
7.4.300.0030.00316.86
7.4.290.0070.00016.78
7.4.280.0070.00016.70
7.4.270.0040.00416.81
7.4.260.0000.00613.61
7.4.250.0000.00716.78
7.4.240.0000.00716.87
7.4.230.0070.00016.60
7.4.220.0140.00316.94
7.4.210.0070.00716.91
7.4.200.0050.00316.73
7.4.190.0000.00717.05
7.4.160.0140.00316.69
7.4.150.0000.01817.40
7.4.140.0080.01017.86
7.4.130.0100.00716.85
7.4.120.0100.00816.91
7.4.110.0130.00316.64
7.4.100.0080.01016.95
7.4.90.0130.01016.64
7.4.80.0120.00619.39
7.4.70.0140.00316.87
7.4.60.0090.00916.98
7.4.50.0040.00416.38
7.4.40.0080.00522.77
7.4.30.0110.01116.85
7.4.00.0110.00515.23
7.3.330.0020.00213.50
7.3.320.0080.00013.45
7.3.310.0070.00016.52
7.3.300.0040.00416.59
7.3.290.0080.00516.63
7.3.280.0090.00816.63
7.3.270.0030.01417.40
7.3.260.0080.01218.24
7.3.250.0090.00916.91
7.3.240.0130.01216.78
7.3.230.0070.01016.75
7.3.210.0090.00916.73
7.3.200.0150.00919.39
7.3.190.0110.01016.62
7.3.180.0130.00316.77
7.3.170.0060.01216.82
7.3.160.0070.01416.71
7.3.120.0100.00815.07
7.3.110.0070.01115.02
7.3.100.0060.00315.11
7.3.90.0100.00714.81
7.3.80.0070.00715.27
7.3.70.0070.00714.88
7.3.60.0060.00615.13
7.3.50.0000.01015.02
7.3.40.0030.00714.87
7.3.30.0140.00415.06
7.3.20.0100.00716.89
7.3.10.0070.01016.56
7.3.00.0030.00916.86
7.2.330.0100.00617.12
7.2.320.0090.00916.85
7.2.310.0090.00917.13
7.2.300.0040.01216.85
7.2.290.0140.00716.80
7.2.250.0100.00614.99
7.2.240.0080.00815.29
7.2.230.0080.01115.40
7.2.220.0090.00915.33
7.2.210.0040.00815.40
7.2.200.0070.01015.01
7.2.190.0060.00915.01
7.2.180.0030.00915.30
7.2.170.0060.00915.35
7.2.60.0100.00716.92
7.2.00.0030.01019.79
7.1.330.0030.01015.82
7.1.320.0000.00916.18
7.1.310.0030.01016.02
7.1.300.0080.00615.96
7.1.290.0060.00315.88
7.1.280.0040.01115.99
7.1.270.0100.00715.96
7.1.260.0040.00816.00
7.1.200.0060.00615.74
7.1.100.0000.01317.98
7.1.70.0080.00317.32
7.1.60.0160.01019.40
7.1.50.0100.01016.93
7.1.00.0000.03722.53
7.0.200.0000.00717.05
7.0.140.0030.07322.16
7.0.70.0000.08321.80
7.0.60.0100.06721.71
7.0.50.0070.08722.16
7.0.40.0030.08320.18
7.0.30.0030.08020.18
7.0.20.0100.06720.19
7.0.10.0100.08020.14
7.0.00.0030.09020.15
5.6.280.0100.06721.04
5.6.220.0070.07320.62
5.6.210.0100.07720.74
5.6.200.0070.08321.13
5.6.190.0030.07721.21
5.6.180.0030.09021.21
5.6.170.0030.08721.05
5.6.160.0030.09021.21
5.6.150.0030.08321.21
5.6.140.0030.09021.02
5.6.130.0100.05321.27
5.6.120.0130.08021.09
5.6.110.0100.07321.20
5.6.100.0070.05721.19
5.6.90.0030.09021.12
5.6.80.0100.06020.59
5.6.70.0030.08720.49
5.6.60.0100.07320.65
5.6.50.0070.08020.53
5.6.40.0070.05320.54
5.6.30.0000.06720.55
5.6.20.0030.06720.50
5.6.10.0030.08020.56
5.6.00.0000.08020.62
5.5.360.0100.08320.56
5.5.350.0030.07320.46
5.5.340.0030.08320.96
5.5.330.0030.08320.99
5.5.320.0030.08020.89
5.5.310.0100.08320.86
5.5.300.0100.07020.90
5.5.290.0000.06020.96
5.5.280.0030.09020.82
5.5.270.0030.08020.95
5.5.260.0130.07720.93
5.5.250.0100.08020.81
5.5.240.0070.07720.19
5.5.230.0100.08320.45
5.5.220.0100.07020.18
5.5.210.0100.07320.36
5.5.200.0070.07020.26
5.5.190.0000.08020.34
5.5.180.0030.05720.34
5.5.160.0030.05320.38
5.5.150.0000.06720.33
5.5.140.0000.08720.23
5.5.130.0070.08020.34
5.5.120.0170.07320.31
5.5.110.0130.06720.36
5.5.100.0070.07320.26
5.5.90.0030.06020.16
5.5.80.0070.06020.23
5.5.70.0100.04720.04
5.5.60.0100.05020.25
5.5.50.0000.08020.27
5.5.40.0000.08020.13
5.5.30.0000.07320.10
5.5.20.0000.05720.12
5.5.10.0030.05320.18
5.5.00.0000.06020.17
5.4.450.0070.07719.58
5.4.440.0000.08319.44
5.4.430.0000.08719.34
5.4.420.0000.07719.44
5.4.410.0030.06319.43
5.4.400.0030.08018.95
5.4.390.0030.04319.27
5.4.380.0030.07319.23
5.4.370.0070.06319.26
5.4.360.0030.07719.26
5.4.350.0070.07019.02
5.4.340.0030.07319.29
5.4.320.0070.07719.23
5.4.310.0000.07718.95
5.4.300.0030.04719.34
5.4.290.0030.07719.27
5.4.280.0000.08318.91
5.4.270.0070.06019.25
5.4.260.0030.06719.16
5.4.250.0070.05019.22
5.4.240.0100.05019.27
5.4.230.0030.04719.11
5.4.220.0100.07719.10
5.4.210.0000.06019.22
5.4.200.0100.07019.27
5.4.190.0030.05319.25
5.4.180.0030.08019.25
5.4.170.0070.07718.88
5.4.160.0030.07319.23
5.4.150.0000.08019.23
5.4.140.0070.04016.63
5.4.130.0030.05316.63
5.4.120.0070.03316.54
5.4.110.0000.07716.52
5.4.100.0030.04316.66
5.4.90.0030.05316.61
5.4.80.0000.07716.62
5.4.70.0100.07316.62
5.4.60.0100.06316.57
5.4.50.0070.07016.73
5.4.40.0030.07016.57
5.4.30.0030.07716.56
5.4.20.0100.05316.73
5.4.10.0130.03016.49
5.4.00.0030.06015.97
5.3.290.0030.05314.86
5.3.280.0000.05314.88
5.3.270.0000.06714.75
5.3.260.0070.05314.70
5.3.250.0100.06714.83
5.3.240.0030.08014.77
5.3.230.0000.06014.84
5.3.220.0070.07314.71
5.3.210.0030.08014.80
5.3.200.0030.07714.84
5.3.190.0000.07714.77
5.3.180.0070.07314.72
5.3.170.0070.07014.73
5.3.160.0070.07314.63
5.3.150.0130.06314.61
5.3.140.0030.06314.73
5.3.130.0100.07314.72
5.3.120.0070.05714.84
5.3.110.0030.07314.80
5.3.100.0070.06314.23
5.3.90.0070.07014.25
5.3.80.0030.06314.18
5.3.70.0000.06014.01
5.3.60.0100.07014.14
5.3.50.0030.06714.13
5.3.40.0000.07014.09
5.3.30.0030.07314.09
5.3.20.0030.05013.84
5.3.10.0100.07313.89
5.3.00.0030.07713.82
5.2.170.0000.06712.32
5.2.160.0030.05012.32
5.2.150.0000.06312.32
5.2.140.0000.05712.32
5.2.130.0030.05312.32
5.2.120.0030.06312.32
5.2.110.0030.06012.32
5.2.100.0030.05312.32
5.2.90.0000.04312.32
5.2.80.0030.04312.32
5.2.70.0030.06712.32
5.2.60.0030.06312.32
5.2.50.0030.04712.32
5.2.40.0070.05712.32
5.2.30.0030.06012.32
5.2.20.0030.06312.32
5.2.10.0030.06012.32
5.2.00.0030.06312.32
5.1.60.0070.05012.32
5.1.50.0070.05012.32
5.1.40.0070.04712.32
5.1.30.0000.04712.32
5.1.20.0030.03012.32
5.1.10.0070.04712.32
5.1.00.0030.05312.32
5.0.50.0030.04012.32
5.0.40.0070.04012.32
5.0.30.0070.06012.32
5.0.20.0000.04312.32
5.0.10.0000.04312.32
5.0.00.0000.06712.32
4.4.90.0030.03312.32
4.4.80.0000.03712.32
4.4.70.0000.03012.32
4.4.60.0030.03312.32
4.4.50.0030.03312.32
4.4.40.0030.04012.32
4.4.30.0000.03312.32
4.4.20.0030.03712.32
4.4.10.0070.03312.32
4.4.00.0000.05712.32
4.3.110.0000.04012.32
4.3.100.0000.03312.32
4.3.90.0000.03012.32
4.3.80.0000.05312.32
4.3.70.0030.02712.32
4.3.60.0000.03312.32
4.3.50.0000.03012.32
4.3.40.0000.04312.32
4.3.30.0000.02712.32
4.3.20.0000.03712.32
4.3.10.0000.04012.32
4.3.00.0030.03712.32

preferences:
40.64 ms | 401 KiB | 5 Q