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 . '[' . $offset . ']'); $target = $target[0]; return new self($target->asXML(), false); } return 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']; var_dump($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.00918.80
8.3.50.0120.00822.11
8.3.40.0150.00019.35
8.3.30.0090.00619.21
8.3.20.0050.00319.14
8.3.10.0080.00021.42
8.3.00.0040.00423.73
8.2.180.0110.01116.96
8.2.170.0070.00722.96
8.2.160.0070.00720.70
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00320.28
8.2.110.0100.00020.88
8.2.100.0110.00018.53
8.2.90.0000.00919.71
8.2.80.0040.00418.41
8.2.70.0030.00618.25
8.2.60.0040.00418.30
8.2.50.0040.00418.25
8.2.40.0050.00318.59
8.2.30.0050.00321.69
8.2.20.0030.00618.08
8.2.10.0050.00318.15
8.2.00.0040.00418.14
8.1.280.0090.00625.92
8.1.270.0050.00323.99
8.1.260.0100.00326.35
8.1.250.0080.00028.09
8.1.240.0090.00022.84
8.1.230.0060.00621.40
8.1.220.0040.00418.77
8.1.210.0040.00419.41
8.1.200.0040.00417.73
8.1.190.0000.00718.03
8.1.180.0040.00418.10
8.1.170.0080.00018.96
8.1.160.0050.00219.23
8.1.150.0040.00419.06
8.1.140.0050.00317.90
8.1.130.0030.00318.16
8.1.120.0000.00717.94
8.1.110.0030.00617.81
8.1.100.0000.00817.89
8.1.90.0040.00417.96
8.1.80.0040.00417.96
8.1.70.0030.00317.82
8.1.60.0000.00818.03
8.1.50.0030.00617.90
8.1.40.0050.00317.80
8.1.30.0040.00417.93
8.1.20.0030.00617.99
8.1.10.0040.00418.09
8.1.00.0000.00817.80
8.0.300.0040.00420.41
8.0.290.0070.00017.54
8.0.280.0040.00418.81
8.0.270.0080.00017.71
8.0.260.0050.00317.39
8.0.250.0040.00417.39
8.0.240.0080.00017.27
8.0.230.0000.00717.26
8.0.220.0030.00317.39
8.0.210.0070.00017.42
8.0.200.0080.00017.42
8.0.190.0050.00417.32
8.0.180.0040.00417.23
8.0.170.0050.00317.41
8.0.160.0040.00417.23
8.0.150.0040.00417.29
8.0.140.0000.00817.29
8.0.130.0040.00413.63
8.0.120.0060.00317.15
8.0.110.0000.00717.23
8.0.100.0040.00417.18
8.0.90.0040.00417.32
8.0.80.0030.01317.30
8.0.70.0000.00717.29
8.0.60.0000.00817.22
8.0.50.0040.00417.25
8.0.30.0070.01217.61
8.0.20.0130.00717.63
8.0.10.0040.00417.48
8.0.00.0100.01317.20
7.4.330.0050.00015.07
7.4.320.0030.00316.78
7.4.300.0000.00616.93
7.4.290.0000.00717.04
7.4.280.0000.00716.90
7.4.270.0070.00017.08
7.4.260.0050.00013.74
7.4.250.0080.00016.98
7.4.240.0030.00617.12
7.4.230.0040.00417.08
7.4.220.0100.01016.86
7.4.210.0080.00717.01
7.4.200.0040.00416.96
7.4.190.0040.00417.09
7.4.160.0130.01016.92
7.4.150.0110.00717.40
7.4.140.0080.01017.86
7.4.130.0090.01216.88
7.4.120.0100.00816.92
7.4.110.0120.00616.93
7.4.100.0140.01016.89
7.4.90.0160.00816.78
7.4.80.0070.01019.37
7.4.70.0120.00616.91
7.4.60.0100.01316.80
7.4.50.0060.00316.81
7.4.40.0030.00922.52
7.4.30.0070.01016.95
7.4.10.0030.01716.93
7.4.00.0080.01015.65
7.3.330.0000.00613.62
7.3.320.0060.00013.80
7.3.310.0040.00416.95
7.3.300.0000.00816.82
7.3.290.0120.00916.84
7.3.280.0100.00816.80
7.3.270.0060.01317.40
7.3.260.0110.01118.24
7.3.250.0160.00717.07
7.3.240.0110.00617.14
7.3.230.0170.00617.05
7.3.210.0120.00616.86
7.3.200.0070.01119.39
7.3.190.0060.01617.14
7.3.180.0040.01717.03
7.3.170.0090.00916.86
7.3.160.0120.00416.95
7.3.130.0100.00616.95
7.3.120.0060.01115.62
7.3.110.0070.01015.88
7.3.100.0070.00915.90
7.3.90.0050.00815.90
7.3.80.0050.00815.88
7.3.70.0060.00516.09
7.3.60.0110.00415.93
7.3.50.0070.00915.94
7.3.40.0070.00815.89
7.3.30.0020.00815.86
7.3.20.0050.00817.78
7.3.10.0090.00517.84
7.3.00.0030.00917.83
7.2.330.0110.00817.27
7.2.320.0120.00617.15
7.2.310.0100.01317.20
7.2.300.0070.01017.25
7.2.290.0120.01117.08
7.2.260.0070.01317.06
7.2.250.0080.00816.10
7.2.240.0070.00816.12
7.2.230.0070.00416.18
7.2.220.0030.00916.19
7.2.210.0050.01116.07
7.2.200.0070.00716.13
7.2.190.0060.00816.06
7.2.180.0090.00916.19
7.2.170.0040.00916.09
7.2.160.0040.01116.90
7.2.150.0030.00718.68
7.2.140.0040.00718.70
7.2.130.0080.00419.02
7.2.120.0040.01118.96
7.2.110.0070.01018.82
7.2.100.0060.01218.80
7.2.90.0060.00918.61
7.2.80.0090.00318.76
7.2.70.0100.00618.86
7.2.60.0070.01017.72
7.2.50.0060.01218.49
7.2.40.0060.00918.89
7.2.30.0030.01018.70
7.2.20.0100.01018.92
7.2.10.0040.01418.75
7.2.00.0130.00719.27
7.1.330.0070.00716.84
7.1.320.0100.00516.91
7.1.310.0050.00916.83
7.1.300.0070.00416.85
7.1.290.0070.00916.78
7.1.280.0060.00616.84
7.1.270.0050.00816.88
7.1.260.0070.00516.82
7.1.250.0040.01217.77
7.1.240.0070.00317.79
7.1.230.0090.00617.84
7.1.220.0070.01017.74
7.1.210.0070.00717.59
7.1.200.0080.00816.77
7.1.190.0040.01117.87
7.1.180.0050.00517.75
7.1.170.0060.00917.85
7.1.160.0030.00917.71
7.1.150.0060.01217.83
7.1.140.0000.01117.87
7.1.130.0100.00717.66
7.1.120.0090.00617.61
7.1.110.0000.01017.60
7.1.100.0060.00617.91
7.1.90.0100.00317.82
7.1.80.0040.01117.70
7.1.70.0090.00317.68
7.1.60.0040.00918.66
7.1.50.0160.01126.39
7.1.40.0090.00617.59
7.1.30.0100.00717.83
7.1.20.0030.01317.86
7.1.10.0050.00517.82
7.1.00.0040.03420.25
7.0.330.0130.00317.41
7.0.320.0070.00717.22
7.0.310.0030.00717.43
7.0.300.0060.01017.59
7.0.290.0070.00717.38
7.0.280.0100.00617.19
7.0.270.0100.00717.32
7.0.260.0030.01217.21
7.0.250.0110.00317.31
7.0.240.0040.01117.36
7.0.230.0040.00717.25
7.0.220.0060.00617.44
7.0.210.0100.00717.38
7.0.200.0030.00717.06
7.0.190.0040.01117.40
7.0.180.0040.01117.58
7.0.170.0040.00917.35
7.0.160.0000.01117.47
7.0.150.0040.00717.52
7.0.140.0070.04019.83
7.0.130.0040.01317.34
7.0.120.0060.00917.24
7.0.110.0060.00917.45
7.0.100.0070.01017.40
7.0.90.0080.02418.75
7.0.80.0080.04818.77
7.0.70.0230.03318.75
7.0.60.0350.03818.80
7.0.50.0200.03519.08
7.0.40.0070.04517.90
7.0.30.0050.04817.83
7.0.20.0070.02217.75
7.0.10.0150.03017.79
7.0.00.0120.04017.77
5.6.400.0100.00716.60
5.6.390.0040.01116.18
5.6.380.0110.00316.32
5.6.370.0060.00816.14
5.6.360.0070.00416.41
5.6.350.0190.00016.55
5.6.340.0040.01116.14
5.6.330.0140.00016.46
5.6.320.0060.00916.42
5.6.310.0090.00616.43
5.6.300.0030.01016.20
5.6.290.0060.00616.16
5.6.280.0050.04218.87
5.6.270.0030.01416.12
5.6.260.0030.01316.27
5.6.250.0000.01016.29
5.6.240.0100.00716.53
5.6.230.0120.03818.50
5.6.220.0020.03518.57
5.6.210.0050.03318.54
5.6.200.0100.04518.82
5.6.190.0080.02318.76
5.6.180.0130.03518.82
5.6.170.0070.04318.63
5.6.160.0070.04718.70
5.6.150.0080.04318.81
5.6.140.0070.04418.74
5.6.130.0070.03218.85
5.6.120.0080.04518.72
5.6.110.0100.04218.76
5.6.100.0080.03518.70
5.6.90.0090.04018.58
5.6.80.0100.03518.29
5.6.70.0110.01818.35
5.6.60.0020.04518.48
5.6.50.0100.04318.41
5.6.40.0100.03818.40
5.6.30.0070.03718.36
5.6.20.0110.03818.36
5.6.10.0050.02718.37
5.6.00.0150.03718.48
5.5.380.0000.01616.21
5.5.370.0050.04318.44
5.5.360.0100.03818.37
5.5.350.0080.04218.52
5.5.340.0120.04018.65
5.5.330.0080.02318.67
5.5.320.0020.02818.60
5.5.310.0110.02318.67
5.5.300.0050.04618.55
5.5.290.0080.02718.63
5.5.280.0080.02818.77
5.5.270.0050.03218.68
5.5.260.0030.04818.58
5.5.250.0070.04518.66
5.5.240.0100.04118.38
5.5.230.0100.03818.34
5.5.220.0080.04118.32
5.5.210.0080.04118.29
5.5.200.0100.03718.42
5.5.190.0040.02718.32
5.5.180.0020.03518.34
5.5.170.0070.01015.91
5.5.160.0000.03318.22
5.5.150.0040.02718.25
5.5.140.0050.04518.23
5.5.130.0090.03518.35
5.5.120.0060.04218.34
5.5.110.0100.02718.46
5.5.100.0060.04118.14
5.5.90.0030.04618.14
5.5.80.0070.04518.13
5.5.70.0050.04518.28
5.5.60.0130.01818.20
5.5.50.0110.03718.14
5.5.40.0080.03818.33
5.5.30.0050.03118.19
5.5.20.0090.04318.15
5.5.10.0060.02818.11
5.5.00.0180.03518.20
5.4.450.0060.04016.46
5.4.440.0080.02516.41
5.4.430.0090.03516.34
5.4.420.0030.04416.43
5.4.410.0110.03816.20
5.4.400.0050.04016.19
5.4.390.0050.04516.19
5.4.380.0080.04016.11
5.4.370.0040.03116.21
5.4.360.0100.03816.16
5.4.350.0030.02716.37
5.4.340.0030.02516.04
5.4.330.0030.01012.76
5.4.320.0020.04016.17
5.4.310.0120.03015.99
5.4.300.0030.04216.13
5.4.290.0060.03616.27
5.4.280.0030.02316.03
5.4.270.0050.03716.16
5.4.260.0100.03516.13
5.4.250.0060.02116.20
5.4.240.0050.04116.07
5.4.230.0050.03916.02
5.4.220.0070.02416.01
5.4.210.0090.04016.08
5.4.200.0050.04016.08
5.4.190.0030.04416.11
5.4.180.0050.03516.05
5.4.170.0100.03816.24
5.4.160.0070.04116.05
5.4.150.0070.03916.11
5.4.140.0070.03914.97
5.4.130.0120.03514.96
5.4.120.0030.02214.83
5.4.110.0050.03814.74
5.4.100.0050.03914.95
5.4.90.0050.02114.91
5.4.80.0030.03614.81
5.4.70.0060.02614.88
5.4.60.0030.02214.82
5.4.50.0050.04414.94
5.4.40.0030.02714.86
5.4.30.0070.01914.92
5.4.20.0020.01914.75
5.4.10.0070.03514.93
5.4.00.0050.02014.54
5.3.290.0060.03614.26
5.3.280.0000.03514.11
5.3.270.0020.02814.17
5.3.260.0090.03414.11
5.3.250.0120.02514.11
5.3.240.0020.04414.08
5.3.230.0050.04314.19
5.3.220.0070.03914.05
5.3.210.0050.04014.04
5.3.200.0050.02214.04
5.3.190.0030.02314.16
5.3.180.0070.02214.20
5.3.170.0050.04314.14
5.3.160.0110.03414.24
5.3.150.0050.04014.11
5.3.140.0050.03614.22
5.3.130.0080.03814.06
5.3.120.0000.02214.04
5.3.110.0030.03914.00
5.3.100.0030.04013.77
5.3.90.0050.03213.90
5.3.80.0070.03813.83
5.3.70.0020.04213.93
5.3.60.0030.03113.77
5.3.50.0020.04413.86
5.3.40.0080.03913.91
5.3.30.0030.04413.75
5.3.20.0050.02013.65
5.3.10.0030.02013.55
5.3.00.0050.03213.54
5.2.170.0100.05313.54
5.2.160.0000.04013.54
5.2.150.0030.05313.54
5.2.140.0000.04313.54
5.2.130.0000.05313.54
5.2.120.0070.05713.54
5.2.110.0130.05313.54
5.2.100.0100.05313.54
5.2.90.0070.04013.54
5.2.80.0070.05713.54
5.2.70.0070.05713.54
5.2.60.0030.02713.54
5.2.50.0070.04713.54
5.2.40.0000.03013.54
5.2.30.0100.02013.54
5.2.20.0030.06313.54
5.2.10.0000.05713.54
5.2.00.0070.04713.54
5.1.60.0030.04013.54
5.1.50.0000.04013.54
5.1.40.0000.03313.54
5.1.30.0030.03313.54
5.1.20.0030.04313.54
5.1.10.0030.02013.54
5.1.00.0070.01713.54
5.0.50.0000.03013.54
5.0.40.0070.04013.54
5.0.30.0030.02713.54
5.0.20.0030.01713.54
5.0.10.0000.04313.54
5.0.00.0070.05713.54
4.4.90.0000.03013.54
4.4.80.0000.03713.54
4.4.70.0100.03013.54
4.4.60.0000.01313.54
4.4.50.0030.03313.54
4.4.40.0030.02313.54
4.4.30.0030.02713.54
4.4.20.0000.01713.54
4.4.10.0030.01313.54
4.4.00.0030.05713.54
4.3.110.0030.02713.54
4.3.100.0000.03713.54
4.3.90.0000.01313.54
4.3.80.0000.05013.54
4.3.70.0000.03313.54
4.3.60.0030.02013.54
4.3.50.0000.02713.54
4.3.40.0000.04013.54
4.3.30.0000.03713.54
4.3.20.0000.03713.54
4.3.10.0030.02313.54
4.3.00.0070.02713.54

preferences:
44.86 ms | 401 KiB | 5 Q