多字段去重php


$insert[] = [
'where' => $sv2['cpy_empcode1'],
'card_id' => $sv2['card_id'],
];


$container = array();
$result = array();
$number = 1;
foreach ($insert as $item) {
$key = $item['where'] . '_' . $item['card_id'];
if (empty($container[$key])) {
$container[$key] = $number;
} else {
$container[$key] += $number;
}
}
foreach ($container as $key => $item) {
list($where, $card_id) = explode('_', $key);
$result[] = array('where' => $where, 'card_id' => $card_id);

}
posted @ 2021-12-27 14:31  Smile☆  阅读(125)  评论(0编辑  收藏  举报