我有两个独立的mysql查询的数组数据。阵列数据如下所示:如何从多维数组中删除重复值?
0
:
{user_id: 82, ac_type: 1,…}
1
:
{user_id: 80, ac_type: 5,…}
2
:
{user_id: 76, ac_type: 1,…}
3
:
{user_id: 82, ac_type: 1,…}
4
:
{user_id: 80, ac_type: 5,…}
我想删除重复的数组项。
所以,我的输出将是这样的:
0
:
{user_id: 82, ac_type: 1,…}
1
:
{user_id: 80, ac_type: 5,…}
2
:
{user_id: 76, ac_type: 1,…}
我想USER_ID检查重复。
我已经尝试了以下解决方案,但都没有按要求工作。
$input = array_unique($res, SORT_REGULAR);
$input = array_map("unserialize", array_unique(array_map("serialize", $res)));
我也试过以下。
$results = array();
foreach ($res as $k => $v) {
$results[implode($v)] = $v;
}
$results = array_values($results);
print_r($results);
但仍存在重复数据。
哇我看到了投票。任何具体原因? – Ironic
我也没有得到那种低调。猜猜这是在这个小时询问的风险。许多用户发送垃圾邮件随机票的徽章或其他东西.. – icecub
@icecub我试图正确地解释问题。还搜索了答案。还提到了我曾经尝试过的。但仍然下降。 – Ironic