I have an array of arrays like this:
Array
(
[userId] => 35
[fieldId] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 1
[4] => 2
[5] => 2
[6] => 1
[7] => 4
)
[educationTitle] => Array
(
[0] => School1
[1] => School2
[2] => 3
[3] => School1
[4] => School2
[5] => School2
[6] => School1
[7] =>
)
)
I want to remove all duplicates of each array. So, I want the final array to look like this:
Array
(
[userId] => 35
[fieldId] => Array
(
[0] => 1
[1] => 2
[2] => 3
[7] => 4
)
[educationTitle] => Array
(
[0] => School1
[1] => School2
[2] => 3
[7] =>
)
)
I've tried this (as recommended in this answer https://stackoverflow.com/a/307701/1009116):
function multi_unique($updates) {
foreach ($updates as $k=>$na)
$new[$k] = serialize($na);
$uniq = array_unique($new);
foreach($uniq as $k=>$ser)
$new1[$k] = unserialize($ser);
return ($new1);
}
And it has no effect
I also tried this (as recommended here - https://stackoverflow.com/a/946300/1009116)
$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
And this just returns the last array (however, it is filtered as it should be)
What am I doing wrong???