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); }*/ 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.0040.01416.88
8.3.50.0110.00922.03
8.3.40.0090.00619.01
8.3.30.0000.01419.31
8.3.20.0140.00020.45
8.3.10.0000.00823.79
8.3.00.0050.00320.90
8.2.180.0070.01118.46
8.2.170.0040.01122.96
8.2.160.0070.00720.69
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0110.00426.16
8.2.120.0040.00422.36
8.2.110.0030.01020.80
8.2.100.0040.00818.16
8.2.90.0040.00419.20
8.2.80.0040.00418.18
8.2.70.0030.00617.75
8.2.60.0040.00418.18
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0030.00518.23
8.2.20.0070.00018.02
8.2.10.0080.00017.89
8.2.00.0000.00817.93
8.1.280.0110.00425.92
8.1.270.0040.00423.96
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0060.00322.38
8.1.230.0100.00324.03
8.1.220.0060.00318.01
8.1.210.0040.00418.77
8.1.200.0030.00617.61
8.1.190.0070.00317.79
8.1.180.0080.00018.10
8.1.170.0030.00619.00
8.1.160.0050.00322.32
8.1.150.0070.00018.94
8.1.140.0030.00617.72
8.1.130.0070.00017.97
8.1.120.0040.00417.73
8.1.110.0080.00017.58
8.1.100.0000.00717.67
8.1.90.0000.01017.63
8.1.80.0030.00317.72
8.1.70.0070.00017.70
8.1.60.0040.00417.83
8.1.50.0000.00917.85
8.1.40.0020.00517.78
8.1.30.0030.00617.77
8.1.20.0040.00417.76
8.1.10.0040.00417.80
8.1.00.0000.00717.68
8.0.300.0000.00718.77
8.0.290.0000.00817.43
8.0.280.0000.00718.66
8.0.270.0000.00817.39
8.0.260.0030.00317.18
8.0.250.0000.00717.14
8.0.240.0000.00717.20
8.0.230.0070.00017.17
8.0.220.0000.00817.23
8.0.210.0040.00417.13
8.0.200.0000.00617.34
8.0.190.0040.00417.21
8.0.180.0040.00417.20
8.0.170.0040.00417.13
8.0.160.0000.00717.17
8.0.150.0050.00317.09
8.0.140.0000.00817.18
8.0.130.0030.00313.64
8.0.120.0050.00517.14
8.0.110.0050.00217.15
8.0.100.0040.00417.15
8.0.90.0030.00517.18
8.0.80.0070.01417.17
8.0.70.0080.00017.14
8.0.60.0030.00517.25
8.0.50.0030.00517.26
8.0.30.0110.00917.22
8.0.20.0130.00717.43
8.0.10.0040.00417.27
8.0.00.0080.01017.03
7.4.330.0000.00515.19
7.4.320.0030.00316.73
7.4.300.0060.00016.88
7.4.290.0070.00016.73
7.4.280.0080.00016.80
7.4.270.0000.00716.72
7.4.260.0000.00816.82
7.4.250.0070.00016.82
7.4.240.0000.00716.75
7.4.230.0000.00816.89
7.4.220.0080.00816.94
7.4.210.0070.00716.82
7.4.200.0000.00716.95
7.4.190.0000.00716.66
7.4.160.0030.01316.77
7.4.150.0060.01217.40
7.4.140.0140.00717.86
7.4.130.0060.01016.70
7.4.120.0110.00916.88
7.4.110.0070.01016.79
7.4.100.0000.01616.60
7.4.90.0050.01116.80
7.4.80.0000.02119.39
7.4.70.0210.01116.79
7.4.60.0060.01016.53
7.4.50.0000.00816.68
7.4.40.0090.00622.77
7.4.30.0060.01017.00
7.4.00.0040.01415.18
7.3.330.0000.00613.42
7.3.320.0030.00313.50
7.3.310.0000.00716.50
7.3.300.0030.00316.69
7.3.290.0110.00916.67
7.3.280.0090.00816.61
7.3.270.0110.00717.40
7.3.260.0070.01016.61
7.3.250.0140.00316.78
7.3.240.0060.01216.57
7.3.230.0060.01016.81
7.3.210.0110.00716.71
7.3.200.0130.01019.39
7.3.190.0100.00716.68
7.3.180.0110.00516.73
7.3.170.0180.00316.61
7.3.160.0140.00316.71
7.3.120.0100.00715.00
7.3.00.0060.00617.07
7.2.330.0000.01716.93
7.2.320.0130.00417.03
7.2.310.0130.00317.03
7.2.300.0100.00717.09
7.2.290.0140.00416.87
7.2.130.0000.01117.36
7.2.120.0070.01017.06
7.2.110.0090.00317.09
7.2.100.0060.00617.06
7.2.90.0040.00917.18
7.2.80.0030.00617.07
7.2.70.0110.00016.98
7.2.60.0060.00317.14
7.2.50.0070.00717.00
7.2.40.0100.00317.13
7.2.30.0070.00717.17
7.2.20.0000.01516.91
7.2.10.0080.00617.04
7.2.00.0040.00718.29
7.1.250.0070.00316.03
7.1.240.0030.00615.63
7.1.230.0120.00016.04
7.1.220.0070.00715.93
7.1.210.0040.01115.92
7.1.200.0000.01315.94
7.1.190.0040.01115.93
7.1.180.0070.00715.70
7.1.170.0080.00016.11
7.1.160.0100.00615.91
7.1.150.0030.01215.62
7.1.140.0070.00715.90
7.1.130.0070.00315.78
7.1.120.0060.00616.08
7.1.110.0100.00016.13
7.1.100.0080.00617.21
7.1.90.0030.01015.91
7.1.80.0050.00515.88
7.1.70.0050.00316.54
7.1.60.0050.01017.54
7.1.50.0130.00116.46
7.1.40.0030.00715.99
7.1.30.0030.01015.94
7.1.20.0050.00815.79
7.1.10.0030.01015.67
7.1.00.0030.04319.20
7.0.330.0030.00715.23
7.0.320.0000.00715.22
7.0.310.0000.00815.43
7.0.300.0000.01315.29
7.0.290.0090.00315.49
7.0.280.0070.00715.56
7.0.270.0090.00315.23
7.0.260.0080.00415.61
7.0.250.0040.01215.56
7.0.240.0030.00915.48
7.0.230.0030.01315.56
7.0.220.0110.00415.53
7.0.210.0000.01415.43
7.0.200.0020.00816.34
7.0.190.0060.00615.47
7.0.180.0080.00615.53
7.0.170.0100.00315.34
7.0.160.0090.00315.59
7.0.150.0000.01315.63
7.0.140.0060.03618.73
7.0.130.0100.00315.71
7.0.120.0030.00515.54
7.0.110.0070.00715.69
7.0.100.0090.00615.52
7.0.90.0060.00915.63
7.0.80.0050.02817.71
7.0.70.0030.02917.75
7.0.60.0130.03717.79
7.0.50.0080.04518.07
7.0.40.0050.04916.79
7.0.30.0100.02716.74
7.0.20.0070.03416.78
7.0.10.0030.05016.90
7.0.00.0000.05016.84
5.6.380.0070.00714.37
5.6.370.0030.00914.41
5.6.360.0080.00314.93
5.6.350.0040.00414.35
5.6.340.0060.00614.66
5.6.330.0000.01014.56
5.6.320.0070.00414.92
5.6.310.0100.00314.63
5.6.300.0040.00714.49
5.6.290.0030.00914.80
5.6.280.0030.04017.81
5.6.270.0030.00614.43
5.6.260.0000.01414.66
5.6.250.0030.00714.58
5.6.240.0090.00314.49
5.6.230.0100.04717.72
5.6.220.0100.04317.71
5.6.210.0060.03017.79
5.6.200.0080.04317.88
5.6.190.0030.03617.79
5.6.180.0120.04117.83
5.6.170.0100.04217.66
5.6.160.0050.02817.72
5.6.150.0080.04517.82
5.6.140.0030.05017.98
5.6.130.0130.04017.96
5.6.120.0110.04617.88
5.6.110.0120.04118.03
5.6.100.0060.04018.03
5.6.90.0100.03517.65
5.6.80.0040.04617.40
5.6.70.0050.04717.58
5.6.60.0030.03017.59
5.6.50.0030.04917.46
5.6.40.0050.04317.47
5.6.30.0080.03917.54
5.6.20.0080.03317.58
5.6.10.0070.04017.49
5.6.00.0080.04117.32
5.5.380.0030.00611.65
5.5.370.0060.04315.86
5.5.360.0060.02915.81
5.5.350.0030.03415.85
5.5.340.0080.03216.23
5.5.330.0140.03816.06
5.5.320.0030.04716.09
5.5.310.0110.03816.05
5.5.300.0070.04016.15
5.5.290.0120.04016.30
5.5.280.0100.04316.07
5.5.270.0050.02716.18
5.5.260.0080.04516.11
5.5.250.0080.03016.09
5.5.240.0080.04115.80
5.5.230.0060.04215.84
5.5.220.0100.02815.83
5.5.210.0070.04115.87
5.5.200.0030.04515.79
5.5.190.0030.04415.82
5.5.180.0050.04115.79
5.5.170.0120.00011.13
5.5.160.0080.04215.85
5.5.150.0050.03215.89
5.5.140.0030.04315.80
5.5.130.0070.03915.78
5.5.120.0110.03815.72
5.5.110.0060.03815.85
5.5.100.0030.04215.76
5.5.90.0050.04015.83
5.5.80.0030.04115.85
5.5.70.0070.03615.65
5.5.60.0050.03815.66
5.5.50.0070.03915.84
5.5.40.0050.03815.62
5.5.30.0020.04215.67
5.5.20.0100.02315.73
5.5.10.0130.03015.75
5.5.00.0050.02715.74
5.4.450.0070.04415.37
5.4.440.0030.04515.50
5.4.430.0040.02815.33
5.4.420.0070.03715.35
5.4.410.0100.02515.36
5.4.400.0130.03715.18
5.4.390.0100.03315.27
5.4.380.0030.04015.16
5.4.370.0080.03915.24
5.4.360.0030.03815.00
5.4.350.0120.03615.14
5.4.340.0020.04315.04
5.4.330.0000.00911.26
5.4.320.0080.03315.20
5.4.310.0060.04115.22
5.4.300.0050.04015.13
5.4.290.0070.04315.24
5.4.280.0070.04315.18
5.4.270.0110.03815.16
5.4.260.0070.04015.08
5.4.250.0100.03515.31
5.4.240.0080.03015.13
5.4.230.0020.04515.14
5.4.220.0000.04815.40
5.4.210.0050.03415.26
5.4.200.0100.03515.13
5.4.190.0080.03015.28
5.4.180.0050.02315.25
5.4.170.0030.02815.13
5.4.160.0030.04015.28
5.4.150.0020.02815.28
5.4.140.0090.03713.95
5.4.130.0050.02813.88
5.4.120.0030.03913.98
5.4.110.0070.03713.91
5.4.100.0080.03613.96
5.4.90.0040.04013.91
5.4.80.0080.03813.79
5.4.70.0090.03713.82
5.4.60.0030.03813.90
5.4.50.0060.04413.93
5.4.40.0090.03913.94
5.4.30.0030.03013.91
5.4.20.0070.03513.88
5.4.10.0030.03613.83
5.4.00.0070.02813.56
5.3.290.0060.04012.88
5.3.280.0180.02812.84
5.3.270.0020.04512.81
5.3.260.0030.04212.82
5.3.250.0030.02912.83
5.3.240.0010.03612.92
5.3.230.0100.03512.85
5.3.220.0060.04112.90
5.3.210.0080.04112.82
5.3.200.0090.03512.82
5.3.190.0070.03912.82
5.3.180.0060.04112.92
5.3.170.0080.04012.79
5.3.160.0110.02712.90
5.3.150.0070.04212.86
5.3.140.0080.03812.79
5.3.130.0050.04112.84
5.3.120.0120.03012.90
5.3.110.0030.04212.85
5.3.100.0050.03512.56
5.3.90.0050.04212.62
5.3.80.0070.03412.62
5.3.70.0050.04212.64
5.3.60.0130.03312.63
5.3.50.0080.03512.57
5.3.40.0030.04212.59
5.3.30.0050.03912.53
5.3.20.0030.02912.46
5.3.10.0070.03812.37
5.3.00.0030.04212.32
5.2.170.0020.02711.35
5.2.160.0010.03511.35
5.2.150.0030.03711.35
5.2.140.0090.03111.35
5.2.130.0040.03011.35
5.2.120.0020.03611.35
5.2.110.0070.03311.35
5.2.100.0040.03011.35
5.2.90.0090.02211.35
5.2.80.0030.03211.35
5.2.70.0060.02011.35
5.2.60.0040.03411.35
5.2.50.0070.03011.35
5.2.40.0060.02611.35
5.2.30.0030.03611.35
5.2.20.0050.03311.35
5.2.10.0090.03011.35
5.2.00.0070.03311.35
5.1.60.0030.03011.35
5.1.50.0080.02611.35
5.1.40.0000.02811.35
5.1.30.0080.02711.35
5.1.20.0070.02711.35
5.1.10.0080.02511.35
5.1.00.0030.02911.35
5.0.50.0060.02011.35
5.0.40.0050.02311.35
5.0.30.0050.03311.35
5.0.20.0030.02211.35
5.0.10.0040.02011.35
5.0.00.0010.03111.35
4.4.90.0020.01211.35
4.4.80.0020.01811.35
4.4.70.0020.02011.35
4.4.60.0030.01711.35
4.4.50.0000.02111.35
4.4.40.0040.02811.35
4.4.30.0020.01911.35
4.4.20.0050.01811.35
4.4.10.0030.01811.35
4.4.00.0050.02611.35
4.3.110.0000.02011.35
4.3.100.0050.01711.35
4.3.90.0010.01911.35
4.3.80.0020.02411.35
4.3.70.0020.02011.35
4.3.60.0040.01711.35
4.3.50.0030.01411.35
4.3.40.0020.02311.35
4.3.30.0020.01811.35
4.3.20.0030.01511.35
4.3.10.0020.02011.35
4.3.00.0030.01711.35

preferences:
50.2 ms | 401 KiB | 5 Q