3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = new class([ "item" => [ "I", "am", "a", "animal" => "beaver", ], "callable" => function(){ return true; } ]) implements ArrayAccess { public function __construct(array $initial = []) { foreach ($initial as $k => $v) { if (is_array($v)) { $this->$k = new self($v); } else $this->$k = $v; } } public function offsetGet($offset) { if (!isset($this->$offset)) { return ($this->$offset = new self()); } return $this->$offset; } public function offsetSet($offset, $value) { if (is_array($value)) { $this->$offset = new self($value); } else $this->$offset = $value; } public function offsetUnset($offset) { unset($this->$offset); } public function offsetExists($offset) { return isset($this->$offset); } public function array(self $object = null) : array { $array = []; if ($object === null) $object = $this; foreach ($object as $k => $v) { if ($v instanceof self) { $array[$k] = $this->array($v); } else $array[$k] = $v; } return $array; } public function __invoke(...$args) {} /* more magic here, perhaps ... */ }; $config["item"]["next"] = [ "I", "am", "a", "animal" => "badger", ]; # write undefined index of existing member $config[1][2] = "hello"; # write undefined index $config[5][8][10] = "whatever"; # write more undef index $config[9][10](); # read undef index and invoke it as function var_dump($config->array()); # show flattened array, not needed for iteration and whatever ... ?>

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.0110.01116.75
8.3.50.0100.00516.47
8.3.40.0110.00718.79
8.3.30.0110.00418.79
8.3.20.0000.00920.22
8.3.10.0040.00423.65
8.3.00.0030.00518.03
8.2.180.0130.01018.41
8.2.170.0180.00322.96
8.2.160.0060.00920.35
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0060.00317.86
8.2.110.0090.00320.35
8.2.100.0070.00418.03
8.2.90.0000.01019.16
8.2.80.0000.00817.97
8.2.70.0040.00417.50
8.2.60.0070.00418.03
8.2.50.0030.00518.07
8.2.40.0060.00321.19
8.2.30.0040.00420.59
8.2.20.0040.00417.65
8.2.10.0000.00818.21
8.2.00.0030.00518.26
8.1.280.0070.00725.92
8.1.270.0030.01223.82
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0040.00722.67
8.1.230.0080.00417.79
8.1.220.0040.00417.93
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0040.00417.36
8.1.180.0030.00518.10
8.1.170.0070.00418.71
8.1.160.0030.00722.04
8.1.150.0000.00818.96
8.1.140.0000.00919.53
8.1.130.0000.00817.80
8.1.120.0070.00017.50
8.1.110.0040.00417.49
8.1.100.0080.00017.38
8.1.90.0000.00717.52
8.1.80.0060.00317.47
8.1.70.0040.00417.41
8.1.60.0050.00317.63
8.1.50.0050.00317.49
8.1.40.0070.00317.44
8.1.30.0030.00517.67
8.1.20.0040.00417.63
8.1.10.0040.00417.56
8.1.00.0000.00817.50
8.0.300.0040.00418.77
8.0.290.0060.00316.75
8.0.280.0080.00018.54
8.0.270.0020.00517.22
8.0.260.0040.00417.21
8.0.250.0040.00416.89
8.0.240.0070.00016.86
8.0.230.0000.00716.93
8.0.220.0000.00716.86
8.0.210.0030.00316.82
8.0.200.0000.00716.96
8.0.190.0040.00416.95
8.0.180.0080.00016.97
8.0.170.0070.00016.95
8.0.160.0040.00416.90
8.0.150.0060.00316.97
8.0.140.0000.00716.84
8.0.130.0060.00013.36
8.0.120.0040.00416.78
8.0.110.0070.00016.97
8.0.100.0080.00016.79
8.0.90.0000.00716.96
8.0.80.0030.01016.91
8.0.70.0030.00616.77
8.0.60.0070.00016.80
8.0.50.0030.00516.94
8.0.30.0140.00617.14
8.0.20.0110.01117.40
8.0.10.0030.00516.98
8.0.00.0060.01216.84
7.4.330.0060.00015.08
7.4.320.0060.00016.64
7.4.300.0040.00416.63
7.4.290.0000.00716.54
7.4.280.0040.00416.66
7.4.270.0000.00816.54
7.4.260.0030.00316.57
7.4.250.0070.00016.49
7.4.240.0020.00516.59
7.4.230.0030.00316.52
7.4.220.0060.01616.73
7.4.210.0070.00716.64
7.4.200.0000.00716.36
7.4.160.0160.00716.46
7.4.150.0100.00717.40
7.4.140.0100.01017.86
7.4.130.0130.00916.43
7.4.120.0120.00916.58
7.4.110.0130.00616.46
7.4.100.0090.01316.35
7.4.90.0130.00516.59
7.4.80.0090.00919.39
7.4.70.0100.00716.40
7.4.60.0100.00716.70
7.4.50.0090.00016.21
7.4.40.0090.00916.70
7.4.30.0160.00716.48
7.4.00.0030.01314.97
7.3.330.0000.00513.22
7.3.320.0000.00513.47
7.3.310.0050.00316.30
7.3.300.0070.00016.23
7.3.290.0080.00716.38
7.3.280.0100.01116.40
7.3.270.0130.00517.40
7.3.260.0090.02416.44
7.3.240.0120.01016.29
7.3.230.0090.00916.52
7.3.210.0030.01316.44
7.3.200.0140.00316.33
7.3.190.0140.00716.39
7.3.180.0000.01716.53
7.3.170.0060.01116.47
7.3.160.0110.00716.48
7.3.10.0070.00715.89
7.3.00.0110.01516.31
7.2.330.0150.00616.85
7.2.320.0090.00916.75
7.2.310.0060.01316.55
7.2.300.0090.00916.80
7.2.290.0130.00616.83
7.2.130.0090.00916.80
7.2.120.0070.00716.45
7.2.110.0160.00316.55
7.2.100.0130.00616.74
7.2.90.0090.00916.69
7.2.80.0070.01316.79
7.2.70.0100.00616.40
7.2.60.0090.00716.67
7.2.50.0150.00616.86
7.2.40.0120.00416.41
7.2.30.0060.00916.65
7.2.20.0070.01116.76
7.2.10.0110.00716.52
7.2.00.0090.00717.88
7.1.250.0080.00815.78
7.1.200.0000.01515.89
7.1.100.0090.00018.13
7.1.70.0070.00717.07
7.1.60.0140.01019.50
7.1.50.0000.01816.72
7.1.00.0070.07322.36
7.0.200.0000.00916.68
7.0.60.0070.08319.99
7.0.50.0100.07717.90
7.0.40.0100.08019.96
7.0.30.0230.04320.17
7.0.20.0270.07720.15
7.0.10.0030.04720.19
7.0.00.0030.05320.10
5.6.210.0000.04320.70
5.6.200.0030.04318.20
5.6.190.0130.04320.61
5.6.180.0000.08720.33
5.6.170.0130.04720.54
5.6.160.0170.07320.44
5.6.150.0170.07718.19
5.6.140.0070.03718.18
5.6.130.0070.04318.28
5.6.120.0100.06721.14
5.6.110.0030.08721.11
5.6.100.0070.03720.98
5.6.90.0100.03321.00
5.6.80.0100.07320.43
5.5.350.0000.06020.38
5.5.340.0000.07718.09
5.5.330.0130.08020.35
5.5.320.0200.07720.23
5.5.310.0300.03720.26
5.5.300.0030.04018.03
5.5.290.0100.08018.08
5.5.280.0130.07720.87
5.5.270.0070.04320.63
5.5.260.0030.04020.76
5.5.250.0170.07320.65
5.5.240.0430.05720.34
5.4.450.0270.05319.48
5.4.440.0270.05319.47
5.4.430.0270.05319.50
5.4.420.0270.04719.51
5.4.410.0270.05019.40
5.4.400.0330.06319.12
5.4.390.0270.05319.20
5.4.380.0300.04719.29
5.4.370.0270.04718.98
5.4.360.0330.04719.09
5.4.350.0170.05719.25
5.4.340.0170.05719.21
5.4.320.0330.04319.22
5.4.310.0270.04718.84
5.4.300.0300.04719.09
5.4.290.0300.05319.25
5.4.280.0300.05719.28
5.4.270.0370.04719.14
5.4.260.0370.04719.17
5.4.250.0300.05719.12
5.4.240.0400.06319.24
5.4.230.0400.06719.19
5.4.220.0370.06019.12
5.4.210.0400.05719.13
5.4.200.0400.04019.16
5.4.190.0230.05719.19
5.4.180.0300.04719.01
5.4.170.0270.05019.21
5.4.160.0200.05719.16
5.4.150.0270.05319.00
5.4.140.0300.04716.55
5.4.130.0270.05316.30
5.4.120.0230.05316.50
5.4.110.0400.04016.51
5.4.100.0330.04016.60
5.4.90.0200.05316.51
5.4.80.0270.04316.53
5.4.70.0230.05016.56
5.4.60.0370.04316.39
5.4.50.0330.04316.39
5.4.40.0300.04716.50
5.4.30.0200.05016.44
5.4.20.0270.04316.14
5.4.10.0170.05716.52
5.4.00.0270.04315.77

preferences:
65.65 ms | 401 KiB | 5 Q