i have this rows.
$rows = [
['user' => 1, 'access' => '342'],
['user' => 2, 'access' => '765'],
['user' => 3, 'access' => '134'],
['user' => 1, 'access' => '342']
];
i manage to remove duplicate eg: user = 1,
$ids = [];
foreach ($rows as $k => $item) {
if (in_array($item['user'], $ids)){
unset($rows[$k]);
} else {
$ids[] = $item['user'];
}
}
echo json_encode($rows);
the thing is, i want the end result to remove totally the both duplicate. eg: desired output (no more user 1)
[
{"user":2,"access":"765"},
{"user":3,"access":"134"}
]
thank you