3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createArrayMap(iterable $input, string $indexKey, ?string $valueKey = null): array { $map = []; foreach ($input as $obj) { $arr = $obj; $mapKey = $arr[$indexKey]; $value = $valueKey !== null ? $arr[$valueKey] : $obj; if (!array_key_exists($mapKey, $map)) { $map[$mapKey] = []; } $map[$mapKey][] = $value; } return $map; } $data = [ [ 'key' => 'first', 'name' => 'Foo' ], [ 'key' => 'second', 'name' => 'Bar' ], null ]; var_dump(createArrayMap($data, 'key'));

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.70.0140.00716.63
8.3.60.0160.00616.63
8.3.50.0150.00019.89
8.3.40.0000.01518.82
8.3.30.0130.00318.93
8.3.20.0080.00024.18
8.3.10.0000.00824.66
8.3.00.0040.00426.16
8.2.180.0140.00325.92
8.2.170.0070.01319.07
8.2.160.0100.01022.96
8.2.150.0040.00425.66
8.2.140.0050.00224.66
8.2.130.0080.00026.16
8.2.120.0040.00426.16
8.2.110.0100.00021.02
8.2.100.0110.00017.84
8.2.90.0080.00017.75
8.2.80.0030.00618.92
8.2.70.0050.00317.63
8.2.60.0000.00817.63
8.2.50.0000.00817.93
8.2.40.0000.00819.19
8.2.30.0070.00017.83
8.2.20.0000.00820.70
8.2.10.0000.00717.77
8.2.00.0000.00719.39
8.1.280.0140.00425.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00019.54
8.1.230.0040.00722.82
8.1.220.0060.00318.60
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0060.00317.23
8.1.180.0000.00818.10
8.1.170.0080.00017.62
8.1.160.0000.00719.00
8.1.150.0030.00618.57
8.1.140.0080.00017.45
8.1.130.0030.00318.82
8.1.120.0020.00517.42
8.1.110.0050.00317.47
8.1.100.0000.00717.46
8.1.90.0000.00717.37
8.1.80.0040.00417.49
8.1.70.0050.00317.48
8.1.60.0040.00417.55
8.1.50.0030.00617.43
8.1.40.0000.00717.57
8.1.30.0000.00917.56
8.1.20.0080.00017.62
8.1.10.0080.00017.66
8.1.00.0070.00317.52
8.0.300.0040.00418.77
8.0.290.0060.00316.63
8.0.280.0050.00218.51
8.0.270.0070.00016.92
8.0.260.0000.00618.53
8.0.250.0000.00717.02
8.0.240.0000.00716.98
8.0.230.0030.00317.06
8.0.220.0000.00716.87
8.0.210.0040.00416.85
8.0.200.0030.00317.02
8.0.190.0050.00316.99
8.0.180.0050.00316.97
8.0.170.0060.00316.94
8.0.160.0030.00516.93
8.0.150.0050.00316.94
8.0.140.0030.00316.84
8.0.130.0000.00916.74
8.0.120.0090.00916.94
8.0.110.0110.00716.99
8.0.100.0160.00316.75
8.0.90.0130.00716.98
8.0.80.0150.00716.94
8.0.70.0100.01016.90
8.0.60.0190.00016.96
8.0.50.0120.00616.93
8.0.30.0130.00516.82
8.0.20.0110.00817.00
8.0.10.0220.00017.05
8.0.00.0050.00516.97
7.4.330.0040.00015.55
7.4.320.0040.00416.47
7.4.300.0060.00016.52
7.4.290.0040.00416.34
7.4.280.0080.00216.59
7.4.270.0030.00316.54
7.4.260.0080.01216.48
7.4.250.0110.01116.51
7.4.240.0150.00516.46
7.4.230.0120.00916.55
7.4.220.0160.00316.55
7.4.210.0110.00616.40
7.4.200.0180.00016.58
7.4.190.0090.00916.57
7.4.180.0180.00016.59
7.4.160.0190.00016.63
7.4.150.0150.00316.50
7.4.140.0140.00416.34
7.4.130.0150.00316.43
7.4.120.0130.00516.44
7.4.110.0150.00316.43
7.4.100.0140.00316.54
7.4.90.0140.00316.52
7.4.80.0060.01216.43
7.4.70.0180.00016.40
7.4.60.0180.00016.34
7.4.50.0040.01316.41
7.4.40.0110.00716.20
7.4.30.0150.00316.39
7.4.20.0130.00416.35
7.4.10.0160.00316.52
7.4.00.0140.00816.34
7.3.330.0100.01016.38
7.3.320.0110.00916.41
7.3.310.0150.00316.36
7.3.300.0070.01116.30
7.3.290.0170.00016.23
7.3.280.0160.00216.39
7.3.270.0180.00016.38
7.3.260.0100.00716.41
7.3.250.0110.00716.33
7.3.240.0210.00016.19
7.3.230.0140.00616.33
7.3.220.0100.00816.29
7.3.210.0090.01016.11
7.3.200.0150.00016.25
7.3.190.0110.00016.27
7.3.180.0110.00016.24
7.3.170.0090.00316.02
7.3.160.0070.00516.17
7.3.150.0080.00416.26
7.3.140.0030.00916.24
7.3.130.0080.00516.21
7.3.120.0030.00815.98
7.3.110.0060.00616.09
7.3.100.0080.00315.99
7.3.90.0040.00816.21
7.3.80.0090.00315.84
7.3.70.0100.00315.75
7.3.60.0080.00416.09
7.3.50.0040.00716.22
7.3.40.0120.00016.00
7.3.30.0080.00316.50
7.3.20.0060.00617.96
7.3.10.0040.00818.10
7.3.00.0070.00517.99

preferences:
93.39 ms | 401 KiB | 5 Q