<?php
$array = [
['user_id' => 82, 'ac_type' => 1, 'irrelevant' => 'a'],
['user_id' => 80, 'ac_type' => 5, 'irrelevant' => 'b'],
['user_id' => 76, 'ac_type' => 1, 'irrelevant' => 'c'],
['user_id' => 82, 'ac_type' => 1, 'irrelevant' => 'd'],
['user_id' => 80, 'ac_type' => 5, 'irrelevant' => 'e']
];
foreach ($array as $row) {
$compositeKey = $row['user_id'] . '_' . $row['ac_type'];
$result[$compositeKey] ??= $row; // only store if first occurrence of compositeKey
}
var_export(array_values($result)); // re-index and print
preferences:
24.27 ms | 405 KiB | 5 Q