3v4l.org

run code in 300+ PHP versions simultaneously
<?php function condense_duplicates($arrays) { $machine_slot_map = array(); foreach ($arrays as $arr) { $machine_slot_key = "{$arr['MACHINE']}_{$arr['slot']}"; if (array_key_exists($machine_slot_key, $machine_slot_map)) { $lot = $arr['LOT']; if (array_key_exists('Duplicate', $machine_slot_map[$machine_slot_key])) { $curr_duplicates = $machine_slot_map[$machine_slot_key]['Duplicate']; $machine_slot_map[$machine_slot_key]['Duplicate'] = "{$curr_duplicates}, {$lot}"; } else { $machine_slot_map[$machine_slot_key]['Duplicate'] = $lot; } } else { $machine_slot_map[$machine_slot_key] = $arr; } } return array_values($machine_slot_map); } $arrays = array ( array('MACHINE' => 'A1', 'LOT' => 'B1077', 'slot' => 1), array('MACHINE' => 'A2', 'LOT' => 'B0229', 'slot' => 2), array('MACHINE' => 'A2', 'LOT' => 'B0132', 'slot' => 2), array('MACHINE' => 'A2', 'LOT' => 'B3967', 'slot' => 2), array('MACHINE' => 'A3', 'LOT' => 'B2644', 'slot' => 3) ); // echo 'Before:', PHP_EOL; // print_r($arrays); $arrays_with_condensed_duplicates = condense_duplicates($arrays); // echo 'After:', PHP_EOL; print_r($arrays_with_condensed_duplicates); ?>

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.5.00.0120.01220.20
8.4.150.0020.00114.05
8.4.140.0080.01317.72
8.4.130.0080.01317.99
8.4.120.0080.00820.86
8.4.110.0100.01018.76
8.4.100.0160.00917.95
8.4.90.0130.00620.83
8.4.80.0050.00317.84
8.4.70.0060.00818.09
8.4.60.0130.00817.67
8.4.50.0130.00420.56
8.4.40.0130.00717.49
8.4.30.0060.00920.46
8.4.20.0100.01017.83
8.4.10.0120.00919.40
8.3.270.0090.01116.50
8.3.260.0120.00616.63
8.3.250.0050.00918.93
8.3.240.0110.00816.55
8.3.230.0090.00916.34
8.3.220.0030.00519.18
8.3.210.0070.00616.80
8.3.200.0110.00716.80
8.3.190.0120.00716.81
8.3.180.0060.00216.60
8.3.170.0090.01120.69
8.3.160.0070.01017.24
8.3.150.0120.00616.63
8.3.140.0050.00317.13
8.3.130.0060.00318.36
8.3.120.0130.00618.93
8.3.110.0100.00620.94
8.3.100.0080.00016.74
8.3.90.0000.00826.77
8.3.80.0030.00616.63
8.3.70.0000.01518.55
8.3.60.0170.00318.22
8.3.50.0130.00824.47
8.3.40.0100.01022.08
8.3.30.0120.00318.86
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.290.0160.00616.95
8.2.280.0040.00418.35
8.2.270.0070.00719.12
8.2.260.0080.00017.28
8.2.250.0040.00416.64
8.2.240.0080.00018.74
8.2.230.0030.00622.58
8.2.220.0030.00624.06
8.2.210.0120.00826.77
8.2.200.0030.00616.63
8.2.190.0090.00916.63
8.2.180.0210.00025.92
8.2.170.0090.00619.04
8.2.160.0110.01122.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0020.00526.16
8.2.120.0030.00626.35
8.2.110.0030.00722.29
8.2.100.0090.00317.78
8.2.90.0000.00817.75
8.2.80.0060.00318.78
8.2.70.0030.00617.63
8.2.60.0000.01118.05
8.2.50.0050.00318.07
8.2.40.0000.00918.34
8.2.30.0030.00518.27
8.2.20.0040.00418.14
8.2.10.0000.00719.23
8.2.00.0000.00719.32
8.1.330.0130.00616.54
8.1.320.0140.00616.36
8.1.310.0000.00718.55
8.1.300.0080.00019.48
8.1.290.0050.00530.84
8.1.280.0110.00425.92
8.1.270.0060.00323.90
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0030.00622.22
8.1.230.0110.00419.61
8.1.220.0040.00417.76
8.1.210.0040.00418.77
8.1.200.0090.00017.38
8.1.190.0000.00817.13
8.1.180.0040.00418.10
8.1.170.0040.00418.69
8.1.160.0000.00718.91
8.1.150.0000.00718.98
8.1.140.0000.00819.02
8.1.130.0000.00720.10
8.1.120.0040.00417.51
8.1.110.0030.00617.47
8.1.100.0000.00817.48
8.1.90.0000.00817.37
8.1.80.0070.00017.50
8.1.70.0000.00917.38
8.1.60.0000.00817.57
8.1.50.0040.00417.55
8.1.40.0000.00817.45
8.1.30.0060.00317.63
8.1.20.0000.00817.59
8.1.10.0000.00717.56
8.1.00.0030.00517.41
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0040.00418.46
8.0.270.0040.00418.03
8.0.260.0060.00018.49
8.0.250.0030.00316.98
8.0.240.0040.00416.94
8.0.230.0050.00316.87
8.0.220.0000.00716.80
8.0.210.0070.00016.80
8.0.200.0070.00316.98
8.0.190.0000.00716.98
8.0.180.0040.00416.93
8.0.170.0090.00016.84
8.0.160.0000.00716.95
8.0.150.0050.00316.91
8.0.140.0060.00316.75
8.0.130.0000.00613.41
8.0.120.0030.00516.89
8.0.110.0070.00016.73
8.0.100.0040.00416.96
8.0.90.0000.00716.88
8.0.80.0090.01016.91
8.0.70.0000.00816.84
8.0.60.0020.00516.95
8.0.50.0040.00416.77
8.0.30.0100.00617.04
8.0.20.0130.00817.00
8.0.10.0050.00216.83
8.0.00.0050.01516.74
7.4.330.0050.00015.55
7.4.320.0030.00316.52
7.4.300.0000.00716.57
7.4.290.0040.00416.42
7.4.280.0040.00416.59
7.4.270.0000.00716.66
7.4.260.0050.00013.23
7.4.250.0000.00816.59
7.4.240.0070.00016.67
7.4.230.0050.00316.62
7.4.220.0000.00716.69
7.4.210.0040.01116.56
7.4.200.0030.00716.46
7.4.130.0090.01016.48
7.4.120.0220.00716.53
7.4.110.0240.00616.63
7.4.100.0270.00316.55
7.4.90.0220.01316.46
7.4.80.0240.00716.55
7.4.70.0200.00716.49
7.4.60.0180.01116.44
7.4.50.0170.01216.48
7.4.40.0170.01216.47
7.4.30.0230.00716.48
7.4.20.0270.00716.59
7.4.10.0180.00916.54
7.4.00.0130.00716.12
7.3.330.0050.00316.29
7.3.320.0030.00313.33
7.3.310.0000.00716.44
7.3.300.0040.00416.41
7.3.290.0100.00816.37
7.3.260.0140.00316.60
7.3.240.0090.00616.65
7.3.230.0290.00416.45
7.3.220.0230.00716.42
7.3.210.0250.00716.61
7.3.200.0190.01016.62
7.3.190.0150.01616.53
7.3.180.0220.00816.45
7.3.170.0220.01116.34
7.3.160.0170.01716.46
7.3.150.0290.00416.41
7.3.140.0240.00716.27
7.3.130.0250.00516.53
7.3.120.0220.00616.73
7.3.110.0250.00616.53
7.3.100.0220.00916.17
7.3.90.0190.01316.46
7.3.80.0300.00316.53
7.3.70.0210.00716.54
7.3.60.0250.00616.42
7.3.50.0280.00316.44
7.3.40.0210.01016.48
7.3.30.0210.00916.51
7.3.20.0240.00716.41
7.3.10.0200.01216.57
7.3.00.0160.01316.47
7.2.340.0240.00616.48
7.2.330.0260.00716.79
7.2.320.0280.00316.89
7.2.310.0180.01116.77
7.2.300.0250.00816.77
7.2.290.0330.00016.44
7.2.280.0230.00716.60
7.2.270.0200.00816.64
7.2.260.0190.01116.84
7.2.250.0220.01316.71
7.2.240.0240.00516.83
7.2.230.0230.00916.86
7.2.220.0250.00616.77
7.2.210.0160.01616.52
7.2.200.0190.01216.69
7.2.190.0230.01116.74
7.2.180.0180.01516.77
7.2.170.0160.01616.57
7.2.160.0150.01516.72
7.2.150.0170.01716.74
7.2.140.0170.01416.75
7.2.130.0210.01216.67
7.2.120.0230.00916.63
7.2.110.0070.02316.53
7.2.100.0200.00916.61
7.2.90.0250.00616.76
7.2.80.0220.00716.91
7.2.70.0180.01216.61
7.2.60.0190.01016.73
7.2.50.0220.00816.66
7.2.40.0230.01316.82
7.2.30.0620.00716.69
7.2.20.0270.00416.59
7.2.10.0220.00816.56
7.2.00.0260.00516.60

preferences:
43.83 ms | 403 KiB | 5 Q