note 111209 added to function.array-unique
| From: | anonymous | Date: | Sat, 26 Jan 2013 02:42:10 +0000 |
| Subject: | note 111209 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193395@lists.php.net to get a copy of this message | ||
the super_unique() fn by @regeda does not quite work, you need to remove dupes on the way out of the
array depth.
test:
print_r(array_recursive_unique(array("a", "b", "b",
array("c", array("d", "d")), array("c",
array("d")), array("f", "f"), array("f"))));
new fn:
function array_recursive_unique ($arr) {
foreach ($arr as $k => $v)
if (is_array($v))
$arr[$k] = array_recursive_unique($v);
return array_map("unserialize", array_unique(array_map("serialize", $arr)));
}
----
Server IP: 203.211.135.122
Probable Submitter: 220.255.134.238
----
Manual Page -- http://php.net/manual/en/function.array-unique.php
Edit -- https://master.php.net/note/edit/111209
Del: integrated -- https://master.php.net/note/delete/111209/integrated
Del: useless -- https://master.php.net/note/delete/111209/useless
Del: bad code -- https://master.php.net/note/delete/111209/bad+code
Del: spam -- https://master.php.net/note/delete/111209/spam
Del: non-english -- https://master.php.net/note/delete/111209/non-english
Del: in docs -- https://master.php.net/note/delete/111209/in+docs
Del: other reasons-- https://master.php.net/note/delete/111209
Reject -- https://master.php.net/note/reject/111209
Search -- https://master.php.net/manage/user-notes.php