You'd have to create your own function that loops through each array item, and performs a search using [man]array_keys/man for all the keys associated with that value. If the returned array is greater than 1 element long (i.e. count($returnedArray)>1) then you know that the other numbers in that array, are all duplicates.
This seems to work well . . .
function arrayDuplicates($array, $singles=false) {
$single = $dups = array();
foreach($array as $item) {
$keys = array_keys($array, $item);
if(count($keys) > 1) {
foreach($keys as $key) {
/*if(!in_array($key, $dups))
$dups[] = $key;*/
if(!in_array($array[$key], $single)) {
$single[] = $item;
break;
}
if(!in_array($array[$key], $dups))
$dups[] = $array[$key];
}
}
else if(count($keys) == 1) {
$single[] = $item;
}
}
natsort($dups);
natsort($single);
if($singles===false)
return $dups;
else
return $single;
}
$myArray = array('apples', 'oranges', 'bananas', 'hearts', 'stars', 'horseshoes', 'clovers', 'bluemoons', 'hearts', 'oranges', 'green', 'blue', 'apples', 'clovers', 'green', 'clovers', 'hearts');
echo '<pre>';
$duplicates = arrayDuplicates($myArray);
print_r($duplicates);
$singles = arrayDuplicates($myArray, true);
print_r($singles);
Offering the following results:
Array
(
[2] => apples
[3] => clovers
[4] => green
[0] => hearts
[1] => oranges
)
Array
(
[0] => apples
[2] => bananas
[9] => blue
[7] => bluemoons
[6] => clovers
[8] => green
[3] => hearts
[5] => horseshoes
[1] => oranges
[4] => stars
)
[EDIT] Updated the function so it returns all array values, as what the original poster wanted.