note 86607 added to function.array-diff-assoc
| From: | jrajpu10 at gmail dot com | Date: | Sat, 25 Oct 2008 19:57:20 +0000 |
| Subject: | note 86607 added to function.array-diff-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145752@lists.php.net to get a copy of this message | ||
array_diff_assoc can also be used to find the duplicates in an array
Code:
$arr =
array('1','2','3','4','3','2','5');
$uniques = array_unique($arr);
// array_diff will not work here, array_diff_assoc works as it takes the key // in account.
$dups = array_diff_assoc($arr, $uniques);
print_r($dups);
Note: The index of the $dups is not in strict sequential order as expected by C programmer.
----
Server IP: 208.69.120.35
Probable Submitter: 24.211.225.202
----
Manual Page -- http://www.php.net/manual/en/function.array-diff-assoc.php
Edit -- https://master.php.net/note/edit/86607
Del: integrated -- https://master.php.net/note/delete/86607/integrated
Del: useless -- https://master.php.net/note/delete/86607/useless
Del: bad code -- https://master.php.net/note/delete/86607/bad+code
Del: spam -- https://master.php.net/note/delete/86607/spam
Del: non-english -- https://master.php.net/note/delete/86607/non-english
Del: in docs -- https://master.php.net/note/delete/86607/in+docs
Del: other reasons-- https://master.php.net/note/delete/86607
Reject -- https://master.php.net/note/reject/86607
Search -- https://master.php.net/manage/user-notes.php