note 86607 modified in function.array-diff-assoc by danbrown
| From: | danbrown@php.net | Date: | Sun, 26 Oct 2008 02:42:59 +0000 |
| Subject: | note 86607 modified in function.array-diff-assoc by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145756@lists.php.net to get a copy of this message | ||
array_diff_assoc can also be used to find the duplicates in an array
<?php
$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.
--was--
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.
http://php.net/manual/en/function.array-diff-assoc.php