我想删除重复的数组,同时在原始数组中添加一个新的键“duplicates”和重复的总数。使用 PHP 执行此操作的最佳方法是什么?
Array
(
[0] => Array
(
[w] => 10
[r] => 10
[e] => 489
)
[1] => Array
(
[w] => 10
[r] => 10
[e] => 489
)
[2] => Array
(
[w] => 10
[r] => 10
[e] => 489
)
[3] => Array
(
[w] => 20
[r] => 20
[e] => 489
)
[4] => Array
(
[w] => 10
[r] => 10
[e] =>
)
)
会成为:
Array
(
[0] => Array
(
[w] => 10
[r] => 10
[e] => 489
[duplicates] => 2
)
[3] => Array
(
[w] => 20
[r] => 20
[e] => 489
)
[4] => Array
(
[w] => 10
[r] => 10
[e] =>
)
)