我正在获取堆栈删除重复键并将它们分配给一个新数组。
我的数组:
array (
[1] => Array
(
[name] => name1
[actions] => add
)
[2] => Array
(
[name] => name1
[actions] => remove
)
[3] => Array
(
[name] => name2
[actions] => dosomething1
)
[4] => Array
(
[name] => name2
[actions] => dosomething1
)
)
我想要达到的目标:
array (
[1] => Array
(
[name] => name1
[actions] => add
[actions] => remove
)
[2] => Array
(
[name] => name2
[actions] => dosomething1
[actions] => dosomething1
)
)
我试过的:
public function array_unique_multidimensional($input)
{
$serialized = array_map('serialize', $input);
$unique = array_unique($serialized);
return array_intersect_key($input, $unique);
}
它错误地返回相同的数组。任何帮助,将不胜感激。