$users = array(
array(1,'name1'),
array(1,'name1'),
array(2,'name2'),
array(3,'name3')
);
Now after adding the following code, i can make the unique array.
array_map("unserialize", array_unique(array_map("serialize", $users)));
I can count the duplicates with the following code. But it is missing the name field. So, i need to do something to get the name along with the id and count of duplicate.
array_count_values(array_map(function($item) {
return $item['id'];
}, $users));
Do i need to loop the array get something like this? Or is there any other trick in php?
$new_users = array(
array(1,'name1', 2), //two times + descending order
array(2,'name2', 1),
array(3,'name3', 1)
);