我想計數並刪除重複數組。爲了重複,整個數組將具有與另一個的鍵和值的匹配。計數並刪除重複數組
Array
(
[0] => Array
(
[name] => Superman
[time] => 60
)
[1] => Array
(
[name] => Superman
[time] => 60
)
[2] => Array
(
[name] => Superman
[time] => 50
)
[3] => Array
(
[name] => Superman
[time] => 40
)
[4] => Array
(
[name] => Superman
[time] => 50
)
[5] => Array
(
[name] => Superman
[time] => 60
)
)
分爲:
Array
(
[0] => Array
(
[name] => Superman
[time] => 60
[count] => 3
)
[1] => Array
(
[name] => Superman
[time] => 50
[count] => 2
)
[2] => Array
(
[name] => Superman
[time] => 40
)
)
我遇到this answer that can remove the duplicates,但我掙扎,看我怎麼可能指望他們。
$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
哪個是您唯一的密鑰名稱或時間? – 2014-09-11 13:42:15