PHP根据键从多维数组中删除重复项
我有一个多维数组($ array),其中的条目如下所示:
{ ["upload/example.gif"]=> array(5) {
["title"]=> string(12) "This is me"
["excerpt"]=> string(24) "This is a photo of a tree"
["img"]=> string(42) "upload/example.gif"
["link"]=> string(23) "http://www.google.co.uk"
["source"]=> string(6) "custom"
}
}
我需要能够根据键删除$array
中的任何重复值。所以如果我的数组是:
$array = array( ["upload/example.gif"] => etc....
["upload/tree.gif"] => etc....
["upload/example.gif"] => etc....)
我可以删除其中一个["upload/example.gif"] => etc....
数组。
我试过了:
$array = array_map('unserialize', array_unique(array_map('serialize', $array)));
但那没用。
提前致谢。
没有找到相关结果
已邀请:
1 个回复
诞胃
http://php.net/manual/en/function.unset.php