3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateProductArray($database) { return array_reduce($database, function ($result, $entry) { [$model, $storage, $color] = array_values($entry); $result[$model][$storage][$color] = ($result[$model][$storage][$color] ?? 0) + 1; return $result; }, []); } // Example data from the database $database = array( array('model' => 'iPhone 14 Pro', 'storage' => '128gb', 'color' => 'Black'), array('model' => 'iPhone 14 Pro', 'storage' => '256gb', 'color' => 'Blue'), array('model' => 'iPhone 14 Pro', 'storage' => '128gb', 'color' => 'Black'), array('model' => 'iPhone 14 Pro', 'storage' => '256gb', 'color' => 'Red'), array('model' => 'iPhone 14 Pro', 'storage' => '256gb', 'color' => 'Red'), ); $resultArray = generateProductArray($database); print_r($resultArray);

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.4.140.0160.00417.64
8.4.130.0140.00717.66
8.4.120.0110.00925.50
8.4.110.0090.01224.06
8.4.100.0160.00517.83
8.4.90.0090.01120.52
8.4.80.0110.00917.51
8.4.70.0150.00517.66
8.4.60.0140.00618.95
8.4.50.0060.00320.33
8.4.40.0150.00617.52
8.4.30.0040.00420.40
8.4.20.0000.00917.90
8.4.10.0130.00622.23
8.3.270.0110.00816.62
8.3.260.0080.00816.85
8.3.250.0110.00918.88
8.3.240.0100.00916.80
8.3.230.0080.01116.42
8.3.220.0140.00418.89
8.3.210.0120.00621.16
8.3.200.0050.00416.70
8.3.190.0070.00417.27
8.3.180.0130.00618.48
8.3.170.0120.00617.38
8.3.160.0070.01118.62
8.3.150.0070.01120.70
8.3.140.0130.00316.47
8.3.130.0060.00318.34
8.3.120.0130.00618.80
8.3.110.0070.00320.94
8.3.100.0050.00524.06
8.3.90.0060.00326.77
8.3.80.0060.00318.55
8.3.70.0040.01118.38
8.3.60.0000.01518.29
8.3.50.0070.00716.43
8.3.40.0040.01121.87
8.3.30.0070.01518.90
8.3.20.0080.00024.18
8.3.10.0040.00424.66
8.3.00.0090.00026.16
8.2.290.0140.00616.71
8.2.280.0090.00618.54
8.2.270.0110.00717.11
8.2.260.0120.00317.31
8.2.250.0000.00718.51
8.2.240.0030.00617.17
8.2.230.0100.00722.58
8.2.220.0030.00737.54
8.2.210.0080.00826.77
8.2.200.0040.00416.50
8.2.190.0040.01118.41
8.2.180.0090.00616.63
8.2.170.0040.01118.91
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0110.00426.16
8.2.120.0040.00420.95
8.2.110.0060.00322.29
8.2.100.0110.00017.84
8.2.90.0120.00017.75
8.2.80.0220.00717.63
8.2.70.0250.00517.38
8.2.60.0250.00417.38
8.2.50.0310.00017.50
8.2.40.0270.00017.50
8.2.30.0090.00417.48
8.2.20.0070.00417.63
8.2.10.0160.01117.63
8.2.00.0220.00617.13
8.1.330.0120.00716.31
8.1.320.0110.00816.39
8.1.310.0110.00418.22
8.1.300.0030.00618.13
8.1.290.0030.00630.84
8.1.280.0060.01225.92
8.1.270.0040.00424.66
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0030.00622.57
8.1.230.0040.00720.97
8.1.220.0160.00317.13
8.1.210.0300.00017.11
8.1.200.0270.00416.97
8.1.190.0210.01017.00
8.1.180.0250.00617.34
8.1.170.0250.00416.85
8.1.160.0270.00416.88
8.1.150.0220.00517.00
8.1.140.0170.00917.25
8.1.130.0230.00417.12
8.1.120.0190.01017.25
8.1.110.0200.00717.00
8.1.100.0250.00417.25
8.1.90.0220.00417.38
8.1.80.0260.00017.25
8.1.70.0180.00717.53
8.1.60.0330.00317.13
8.1.50.0210.00917.50
8.1.40.0300.00017.00
8.1.30.0360.00017.34
8.1.20.0200.00817.25
8.1.10.0200.00917.25
8.1.00.0230.00317.25
8.0.300.0240.00316.80
8.0.290.0230.00516.80
8.0.280.0240.00516.80
8.0.270.0220.00616.80
8.0.260.0230.00316.80
8.0.250.0230.00416.80
8.0.240.0230.00816.80
8.0.230.0220.00616.80
8.0.220.0240.00516.80
8.0.210.0270.00016.80
8.0.200.0210.00516.80
8.0.190.0280.00016.80
8.0.180.0220.00816.80
8.0.170.0220.00616.80
8.0.160.0210.00916.80
8.0.150.0260.00216.80
8.0.140.0200.00816.80
8.0.130.0230.00416.80
8.0.120.0210.00816.80
8.0.110.0200.00516.80
8.0.100.0270.00016.80
8.0.90.0240.00416.80
8.0.80.0180.00718.26
8.0.70.0240.00616.80
8.0.60.0230.01016.80
8.0.50.0270.00316.80
8.0.30.0180.00916.80
8.0.20.0190.00716.80
8.0.10.0270.00016.80

preferences:
66.05 ms | 403 KiB | 5 Q