我想僅通過值以去除從輸入陣列重複user_id
PHP - 陣列由值獨特在多維數組
輸入數組:
array (size=3)
0 =>
array (size=3)
'user_id' => string '3' (length=1)
'rate' => string '0' (length=1)
'note' => string 'a' (length=1)
1 =>
array (size=3)
'user_id' => string '3' (length=1)
'rate' => string '2' (length=1)
'note' => string 'b' (length=1)
2 =>
array (size=3)
'user_id' => string '4' (length=1)
'rate' => string '3' (length=1)
'note' => string 'c' (length=1)
輸出:
array (size=3)
0 =>
array (size=3)
'user_id' => string '3' (length=1)
'rate' => string '0' (length=1)
'note' => string 'a' (length=1)
1 =>
array (size=3)
'user_id' => string '4' (length=1)
'rate' => string '3' (length=1)
'note' => string 'c' (length=1)
到目前爲止:
$result1 = array_unique($inputArray, SORT_REGULAR);
$result2 = array_map("unserialize", array_unique(array_map("serialize", $inputArray)));
的可能重複(http://stackoverflow.com/questions/307674/how-to-remove-duplicate-values-from- [如何從在PHP多維數組中刪除重複的值] a-multi-dimensional-array-in-php) – Rizier123 2015-02-23 10:11:10
@ Rizier123該職位是由整個數組排序,這是隻有價值在數組 – 2015-02-23 10:12:24
@ Rizier123不,這是不是他想刪除重複只有身份證。 – 2015-02-23 10:12:49