3v4l.org

run code in 300+ PHP versions simultaneously
<?php $nest = new class([ "first" => [ "I", "am", "a", "animal" => "beaver" ] ]) 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 $thing = null) { $result = []; if (!$thing) $thing = $this; foreach ($thing as $k => $v) { if ($v instanceof self) { $result[$k] = $this->array($v); } else $result[$k] = $v; } return $result; } public function __invoke(...$args) {} }; $nest[1][2] = "hello"; # write undefined index $nest[5][8][10] = "whatever"; # write more undef index $nest[9][10](); # read undef index and invoke it var_dump($nest->array()); # show array(s), 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.0060.01016.61
8.3.50.0120.00622.00
8.3.40.0090.00618.83
8.3.30.0070.01018.79
8.3.20.0040.00420.13
8.3.10.0080.00023.39
8.3.00.0060.00318.04
8.2.180.0180.00318.29
8.2.170.0070.00722.96
8.2.160.0100.00320.38
8.2.150.0040.00425.66
8.2.140.0090.00024.66
8.2.130.0030.00626.16
8.2.120.0040.00417.88
8.2.110.0080.00422.25
8.2.100.0040.00818.03
8.2.90.0000.00819.10
8.2.80.0040.00417.97
8.2.70.0050.00517.63
8.2.60.0030.00518.05
8.2.50.0000.01018.07
8.2.40.0030.00620.89
8.2.30.0000.00720.70
8.2.20.0040.00417.82
8.2.10.0000.00818.15
8.2.00.0040.00418.21
8.1.280.0090.00925.92
8.1.270.0040.01524.02
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00622.53
8.1.230.0110.00017.79
8.1.220.0000.00817.80
8.1.210.0040.00418.77
8.1.200.0030.00617.22
8.1.190.0000.00817.13
8.1.180.0030.00818.10
8.1.170.0040.00418.52
8.1.160.0070.00022.04
8.1.150.0030.00618.91
8.1.140.0030.00519.66
8.1.130.0000.00717.77
8.1.120.0000.00717.38
8.1.110.0030.00617.46
8.1.100.0050.00217.53
8.1.90.0030.00517.36
8.1.80.0000.00717.50
8.1.70.0050.00317.50
8.1.60.0000.00817.62
8.1.50.0000.00817.52
8.1.40.0000.01017.53
8.1.30.0040.00417.77
8.1.20.0060.00317.59
8.1.10.0040.00417.64
8.1.00.0030.00617.55
8.0.300.0040.00418.77
8.0.290.0070.00016.75
8.0.280.0000.00818.48
8.0.270.0050.00317.29
8.0.260.0000.00817.23
8.0.250.0040.00416.95
8.0.240.0040.00417.05
8.0.230.0030.00516.88
8.0.220.0000.00716.89
8.0.210.0040.00416.93
8.0.200.0000.00716.89
8.0.190.0030.00517.05
8.0.180.0000.00716.91
8.0.170.0000.00716.93
8.0.160.0040.00416.98
8.0.150.0070.00016.90
8.0.140.0000.00716.77
8.0.130.0000.00613.38
8.0.120.0000.00816.86
8.0.110.0000.00716.79
8.0.100.0000.00716.98
8.0.90.0030.00616.92
8.0.80.0000.01416.97
8.0.70.0040.00416.96
8.0.60.0000.00716.83
8.0.50.0000.00716.87
8.0.30.0090.00917.03
8.0.20.0060.01317.40
8.0.10.0000.00716.92
8.0.00.0040.01516.89
7.4.330.0000.00515.08
7.4.320.0030.00316.46
7.4.300.0080.00016.46
7.4.290.0070.00016.54
7.4.280.0040.00416.52
7.4.270.0080.00016.40
7.4.260.0070.00016.63
7.4.250.0080.00016.57
7.4.240.0000.00716.57
7.4.230.0070.00016.65
7.4.220.0120.00616.61
7.4.210.0080.00816.75
7.4.200.0050.00316.67
7.4.160.0090.00616.60
7.4.150.0200.00317.40
7.4.140.0110.00917.86
7.4.130.0080.00916.56
7.4.120.0070.00916.53
7.4.110.0050.01316.58
7.4.100.0070.01116.60
7.4.90.0100.00716.43
7.4.80.0130.01019.39
7.4.70.0180.00316.48
7.4.60.0030.01316.48
7.4.50.0000.00516.38
7.4.40.0110.00716.58
7.4.30.0000.01716.58
7.4.00.0100.00715.15
7.3.330.0030.00313.36
7.3.320.0030.00313.38
7.3.310.0000.00816.20
7.3.300.0030.00316.38
7.3.290.0070.00716.38
7.3.280.0080.01116.33
7.3.270.0080.01217.40
7.3.260.0070.01116.66
7.3.250.0120.00716.53
7.3.240.0090.01116.37
7.3.230.0130.00316.52
7.3.210.0100.00716.50
7.3.200.0100.00716.55
7.3.190.0060.01416.37
7.3.180.0100.01016.34
7.3.170.0110.01116.38
7.3.160.0130.01016.60
7.2.330.0070.01116.80
7.2.320.0100.01016.75
7.2.310.0070.01016.72
7.2.300.0060.01116.80
7.2.290.0070.01416.54
7.2.60.0030.00917.02
7.1.200.0030.00715.80
7.1.100.0040.00818.13
7.1.70.0130.00717.18
7.1.60.0070.01719.50
7.1.50.0070.01116.95
7.1.00.0000.08022.46
7.0.200.0000.01016.61
7.0.60.0200.07021.84
7.0.50.0100.07717.98
7.0.40.0200.07320.11
7.0.30.0370.03320.06
7.0.20.0270.06720.26
7.0.10.0070.08320.12
7.0.00.0100.08320.12
5.6.280.0000.03720.88
5.6.210.0270.05720.66
5.6.200.0070.05318.18
5.6.190.0000.05320.50
5.6.180.0030.04020.77
5.6.170.0330.05020.54
5.6.160.0030.04320.46
5.6.150.0170.07318.18
5.6.140.0030.03718.16
5.6.130.0100.05718.28
5.6.120.0100.08720.96
5.6.110.0100.08321.07
5.6.100.0030.06320.95
5.6.90.0070.08321.09
5.6.80.0000.04020.39
5.5.350.0230.08020.38
5.5.340.0030.03717.97
5.5.330.0070.05320.40
5.5.320.0100.04720.20
5.5.310.0270.07720.34
5.5.300.0200.06718.08
5.5.290.0070.07317.98
5.5.280.0030.10020.77
5.5.270.0170.07320.79
5.5.260.0130.07320.72
5.5.250.0100.05320.68
5.5.240.0430.06720.02
5.4.450.0370.07319.34
5.4.440.0270.05719.34
5.4.430.0370.05319.43
5.4.420.0370.04719.60
5.4.410.0230.05719.07
5.4.400.0230.05019.15
5.4.390.0270.05318.99
5.4.380.0270.05019.29
5.4.370.0300.04719.13
5.4.360.0170.07018.98
5.4.350.0270.05018.98
5.4.340.0370.04719.02
5.4.320.0270.05319.31
5.4.310.0270.04719.14
5.4.300.0230.05319.27
5.4.290.0370.04019.25
5.4.280.0230.05318.98
5.4.270.0230.05319.01
5.4.260.0330.04019.30
5.4.250.0200.05319.28
5.4.240.0270.05319.12
5.4.230.0330.04719.05
5.4.220.0270.06018.97
5.4.210.0270.05019.14
5.4.200.0330.04318.87
5.4.190.0300.05019.28
5.4.180.0300.05019.05
5.4.170.0330.04318.97
5.4.160.0370.04319.20
5.4.150.0270.07019.23
5.4.140.0270.05316.44
5.4.130.0300.06316.56
5.4.120.0270.06716.56
5.4.110.0330.05316.63
5.4.100.0370.04716.57
5.4.90.0330.04716.52
5.4.80.0270.05016.50
5.4.70.0230.05016.42
5.4.60.0300.05016.63
5.4.50.0270.04716.59
5.4.40.0300.04316.55
5.4.30.0230.05716.61
5.4.20.0200.05316.16
5.4.10.0270.05016.45
5.4.00.0430.04716.05

preferences:
54.39 ms | 401 KiB | 5 Q