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() { if (count($this->xml) > 1) { return (string) $this->xml; } return (string) $this->xml[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'][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.0130.00718.81
8.3.50.0160.00722.22
8.3.40.0040.01119.09
8.3.30.0140.00019.17
8.3.20.0040.00418.91
8.3.10.0000.00821.30
8.3.00.0040.00422.02
8.2.180.0070.01116.75
8.2.170.0100.01022.96
8.2.160.0030.01420.68
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0000.00821.13
8.2.110.0060.00320.77
8.2.100.0120.00017.97
8.2.90.0040.00419.52
8.2.80.0050.00318.18
8.2.70.0060.00617.75
8.2.60.0030.00618.29
8.2.50.0030.00618.07
8.2.40.0040.00418.41
8.2.30.0000.00721.43
8.2.20.0060.00317.98
8.2.10.0030.00517.80
8.2.00.0040.00418.06
8.1.280.0030.01725.92
8.1.270.0050.00323.99
8.1.260.0120.00326.35
8.1.250.0030.00628.09
8.1.240.0000.01022.82
8.1.230.0140.00021.35
8.1.220.0040.00418.77
8.1.210.0040.00419.32
8.1.200.0070.00317.61
8.1.190.0000.00717.91
8.1.180.0040.00418.10
8.1.170.0000.00918.90
8.1.160.0040.00419.03
8.1.150.0000.00818.72
8.1.140.0060.00317.68
8.1.130.0030.00318.06
8.1.120.0000.00717.74
8.1.110.0040.00417.69
8.1.100.0050.00317.63
8.1.90.0070.00017.61
8.1.80.0030.00617.61
8.1.70.0000.00817.62
8.1.60.0030.00617.73
8.1.50.0040.00417.73
8.1.40.0000.00917.72
8.1.30.0000.00817.83
8.1.20.0030.00517.84
8.1.10.0040.00417.81
8.1.00.0070.00317.67
8.0.300.0060.00320.14
8.0.290.0000.00817.27
8.0.280.0040.00418.77
8.0.270.0000.00917.48
8.0.260.0040.00417.17
8.0.250.0000.00817.13
8.0.240.0030.00717.16
8.0.230.0050.00317.29
8.0.220.0030.00317.05
8.0.210.0050.00317.15
8.0.200.0040.00417.26
8.0.190.0080.00017.17
8.0.180.0040.00417.13
8.0.170.0040.00417.22
8.0.160.0030.00517.27
8.0.150.0050.00317.21
8.0.140.0040.00417.19
8.0.130.0030.00313.52
8.0.120.0040.00417.07
8.0.110.0080.00017.13
8.0.100.0030.00517.18
8.0.90.0030.00516.96
8.0.80.0100.01017.22
8.0.70.0050.00216.96
8.0.60.0000.00817.05
8.0.50.0000.00817.07
8.0.30.0130.01017.31
8.0.20.0110.00917.41
8.0.10.0050.00317.35
8.0.00.0120.00717.06
7.4.330.0050.00014.87
7.4.320.0030.00316.88
7.4.300.0030.00316.72
7.4.290.0030.00316.86
7.4.280.0050.00216.81
7.4.270.0030.00316.77
7.4.260.0000.00513.44
7.4.250.0040.00416.77
7.4.240.0040.00416.71
7.4.230.0030.00316.51
7.4.220.0150.00316.76
7.4.210.0100.00516.85
7.4.200.0040.00416.78
7.4.190.0000.00716.84
7.4.160.0060.00916.63
7.4.150.0070.01317.40
7.4.140.0130.00617.86
7.4.130.0090.00916.75
7.4.120.0100.00816.85
7.4.110.0040.01516.83
7.4.100.0030.01316.89
7.4.90.0150.00916.79
7.4.80.0110.00619.39
7.4.70.0120.00416.79
7.4.60.0100.00716.68
7.4.50.0030.00516.91
7.4.40.0070.00722.77
7.4.30.0120.00916.79
7.4.10.0030.01615.18
7.4.00.0080.00815.13
7.3.330.0050.00013.57
7.3.320.0000.00513.40
7.3.310.0030.00316.70
7.3.300.0030.00316.50
7.3.290.0030.01416.68
7.3.280.0080.00816.64
7.3.270.0070.01117.40
7.3.260.0140.00518.24
7.3.250.0120.00916.59
7.3.240.0180.00416.85
7.3.230.0120.00616.87
7.3.210.0110.00616.73
7.3.200.0000.02419.39
7.3.190.0060.01816.83
7.3.180.0070.01116.57
7.3.170.0060.01516.54
7.3.160.0090.00616.87
7.3.130.0130.00615.03
7.3.120.0060.01015.05
7.3.110.0060.00914.96
7.3.100.0080.00614.95
7.3.90.0140.00714.73
7.3.80.0070.00715.04
7.3.70.0090.00314.80
7.3.60.0060.00615.07
7.3.50.0080.00414.95
7.3.40.0060.00614.90
7.3.30.0060.00314.75
7.3.20.0000.01216.85
7.3.10.0070.00716.77
7.3.00.0060.00916.73
7.2.330.0090.01216.91
7.2.320.0080.01117.13
7.2.310.0110.00617.12
7.2.300.0030.01416.68
7.2.290.0140.00417.08
7.2.260.0060.01015.28
7.2.250.0040.01115.27
7.2.240.0040.01115.43
7.2.230.0030.01615.42
7.2.220.0130.00315.35
7.2.210.0030.00915.08
7.2.200.0090.00615.13
7.2.190.0090.00615.11
7.2.180.0060.00615.33
7.2.170.0040.01215.02
7.2.160.0090.00915.38
7.2.150.0060.00317.07
7.2.140.0070.01117.13
7.2.130.0030.01417.23
7.2.120.0090.00916.96
7.2.110.0030.00717.23
7.2.100.0070.00316.98
7.2.90.0040.00817.04
7.2.80.0030.01017.18
7.2.70.0060.00917.02
7.2.60.0000.01416.86
7.2.50.0070.01017.11
7.2.40.0090.00617.03
7.2.30.0090.00617.27
7.2.20.0040.01117.16
7.2.10.0030.01617.26
7.2.00.0060.00818.15
7.1.330.0070.00715.84
7.1.320.0050.00915.86
7.1.310.0000.01316.10
7.1.300.0030.01015.82
7.1.290.0100.00015.98
7.1.280.0120.00315.87
7.1.270.0060.00615.81
7.1.260.0070.00715.71
7.1.250.0000.01615.86
7.1.240.0070.00415.98
7.1.230.0070.00415.80
7.1.220.0040.00815.92
7.1.210.0070.01015.75
7.1.200.0040.00815.84
7.1.190.0080.00415.99
7.1.180.0040.01115.91
7.1.170.0030.00716.11
7.1.160.0000.01215.90
7.1.150.0100.00315.93
7.1.140.0070.01015.86
7.1.130.0090.00615.82
7.1.120.0040.00815.99
7.1.110.0040.00716.00
7.1.100.0050.00717.09
7.1.90.0000.00816.18
7.1.80.0090.00315.98
7.1.70.0040.00816.51
7.1.60.0070.01317.60
7.1.50.0120.00716.53
7.1.40.0120.00016.25
7.1.30.0060.00816.12
7.1.20.0040.01415.59
7.1.10.0080.00315.81
7.1.00.0020.02219.07
7.0.330.0100.00715.25
7.0.320.0060.00615.42
7.0.310.0120.00315.48
7.0.300.0000.00815.51
7.0.290.0030.01015.53
7.0.280.0080.00615.25
7.0.270.0000.00915.54
7.0.260.0030.00915.40
7.0.250.0080.00415.64
7.0.240.0110.00415.53
7.0.230.0000.01515.66
7.0.220.0060.00315.48
7.0.210.0030.00615.57
7.0.200.0030.00716.28
7.0.190.0100.00315.72
7.0.180.0030.01015.48
7.0.170.0100.00315.48
7.0.160.0000.01115.41
7.0.150.0040.01115.66
7.0.140.0050.03918.90
7.0.130.0000.01215.44
7.0.120.0040.01115.82
7.0.110.0030.00715.34
7.0.100.0000.01315.67
7.0.90.0100.00315.51
7.0.80.0020.03517.82
7.0.70.0030.02517.89
7.0.60.0050.02717.71
7.0.50.0080.03518.14
7.0.40.0050.02816.82
7.0.30.0120.01316.85
7.0.20.0050.02616.90
7.0.10.0020.02316.89
7.0.00.0050.04416.84
5.6.400.0080.00414.48
5.6.390.0080.00814.51
5.6.380.0090.00014.63
5.6.370.0040.00714.60
5.6.360.0000.01314.45
5.6.350.0060.00914.69
5.6.340.0080.00414.83
5.6.330.0110.00314.46
5.6.320.0040.01014.52
5.6.310.0070.00414.75
5.6.300.0060.00914.61
5.6.290.0040.01114.91
5.6.280.0070.04017.90
5.6.270.0030.00714.63
5.6.260.0080.00314.54
5.6.250.0070.00714.56
5.6.240.0030.01614.46
5.6.230.0100.03017.61
5.6.220.0050.02517.47
5.6.210.0020.02817.69
5.6.200.0160.01617.81
5.6.190.0080.01818.07
5.6.180.0070.02017.87
5.6.170.0050.04517.76
5.6.160.0080.03717.88
5.6.150.0070.01818.00
5.6.140.0050.02317.77
5.6.130.0120.02017.87
5.6.120.0050.04417.70
5.6.110.0070.02817.77
5.6.100.0120.04017.81
5.6.90.0060.04617.92
5.6.80.0050.02317.47
5.6.70.0060.04317.56
5.6.60.0100.04217.39
5.6.50.0060.04317.46
5.6.40.0090.04417.53
5.6.30.0120.03717.49
5.6.20.0120.03817.50
5.6.10.0050.03417.52
5.6.00.0050.04317.50
5.5.380.0040.01214.38
5.5.370.0070.02717.53
5.5.360.0020.02617.48
5.5.350.0080.03017.63
5.5.340.0030.02317.59
5.5.330.0030.03617.77
5.5.320.0030.02317.77
5.5.310.0030.02317.55
5.5.300.0050.02517.64
5.5.290.0030.04217.73
5.5.280.0070.04717.79
5.5.270.0110.04217.67
5.5.260.0120.04017.56
5.5.250.0130.03717.47
5.5.240.0050.02717.50
5.5.230.0070.04317.40
5.5.220.0060.04117.27
5.5.210.0080.04217.30
5.5.200.0100.03717.38
5.5.190.0060.03117.34
5.5.180.0100.02317.41
5.5.170.0060.00914.25
5.5.160.0050.04317.25
5.5.150.0100.02217.35
5.5.140.0050.02517.36
5.5.130.0120.03317.24
5.5.120.0020.02817.23
5.5.110.0150.03317.27
5.5.100.0080.02717.29
5.5.90.0050.03417.36
5.5.80.0050.03217.34
5.5.70.0080.03117.33
5.5.60.0030.04117.26
5.5.50.0050.03417.31
5.5.40.0060.02117.36
5.5.30.0020.04217.18
5.5.20.0070.02817.31
5.5.10.0030.02917.14
5.5.00.0080.04417.32
5.4.450.0080.03716.29
5.4.440.0030.03816.39
5.4.430.0100.02216.35
5.4.420.0060.02816.40
5.4.410.0030.03516.22
5.4.400.0070.02216.19
5.4.390.0080.02616.08
5.4.380.0080.02216.27
5.4.370.0020.02516.21
5.4.360.0080.03016.24
5.4.350.0070.02016.26
5.4.340.0100.02316.18
5.4.330.0040.00413.23
5.4.320.0100.03316.18
5.4.310.0030.02816.23
5.4.300.0050.02816.24
5.4.290.0100.03616.23
5.4.280.0060.03416.23
5.4.270.0040.04116.23
5.4.260.0030.04116.23
5.4.250.0020.03216.24
5.4.240.0070.04116.24
5.4.230.0070.03316.22
5.4.220.0050.02816.12
5.4.210.0030.04216.24
5.4.200.0000.02516.30
5.4.190.0050.03816.23
5.4.180.0050.02216.07
5.4.170.0020.04516.24
5.4.160.0050.03116.16
5.4.150.0030.02316.23
5.4.140.0070.03714.89
5.4.130.0030.03314.80
5.4.120.0120.03014.93
5.4.110.0030.02714.88
5.4.100.0070.01914.88
5.4.90.0030.04014.90
5.4.80.0060.02914.89
5.4.70.0080.02814.87
5.4.60.0090.02814.94
5.4.50.0020.02514.95
5.4.40.0030.03314.85
5.4.30.0060.02114.83
5.4.20.0060.01814.85
5.4.10.0040.02214.94
5.4.00.0070.01814.57
5.3.290.0060.04114.03
5.3.280.0050.04013.99
5.3.270.0080.01814.04
5.3.260.0020.03813.98
5.3.250.0070.03714.01
5.3.240.0080.03814.05
5.3.230.0080.03413.96
5.3.220.0050.02513.98
5.3.210.0060.03613.91
5.3.200.0030.03914.04
5.3.190.0030.03713.92
5.3.180.0050.03313.92
5.3.170.0000.04113.93
5.3.160.0070.02513.94
5.3.150.0030.04313.97
5.3.140.0050.02713.94
5.3.130.0080.02013.98
5.3.120.0070.02213.91
5.3.110.0040.02614.00
5.3.100.0050.02113.71
5.3.90.0030.02313.63
5.3.80.0020.02513.63
5.3.70.0050.02213.70
5.3.60.0050.03413.74
5.3.50.0040.02213.66
5.3.40.0030.02113.61
5.3.30.0070.03413.57
5.3.20.0000.02213.55
5.3.10.0030.03913.52
5.3.00.0000.02313.55
5.2.170.0030.02712.46
5.2.160.0030.03312.46
5.2.150.0000.03312.46
5.2.140.0000.03312.46
5.2.130.0000.03012.46
5.2.120.0000.03012.46
5.2.110.0000.03012.46
5.2.100.0030.03012.46
5.2.90.0000.02712.46
5.2.80.0030.02312.46
5.2.70.0000.03012.46
5.2.60.0070.02312.46
5.2.50.0000.02712.46
5.2.40.0000.02712.46
5.2.30.0000.03012.46
5.2.20.0000.02712.46
5.2.10.0030.02712.46
5.2.00.0030.02312.46
5.1.60.0000.02712.46
5.1.50.0070.03712.46
5.1.40.0070.04012.46
5.1.30.0030.04012.46
5.1.20.0100.02012.46
5.1.10.0030.03012.46
5.1.00.0030.02312.46
5.0.50.0000.02312.46
5.0.40.0000.02312.46
5.0.30.0030.03012.46
5.0.20.0030.03312.46
5.0.10.0000.02312.46
5.0.00.0030.02712.46
4.4.90.0030.01012.46
4.4.80.0030.01312.46
4.4.70.0000.01312.46
4.4.60.0000.01312.46
4.4.50.0000.01312.46
4.4.40.0100.04712.46
4.4.30.0030.02012.46
4.4.20.0000.01312.46
4.4.10.0000.01712.46
4.4.00.0070.02012.46
4.3.110.0000.01712.46
4.3.100.0030.02712.46
4.3.90.0030.01712.46
4.3.80.0000.02312.46
4.3.70.0000.02012.46
4.3.60.0030.01312.46
4.3.50.0000.03012.46
4.3.40.0000.02712.46
4.3.30.0000.01712.46
4.3.20.0030.01312.46
4.3.10.0000.01312.46
4.3.00.0000.01312.46

preferences:
41.62 ms | 401 KiB | 5 Q