I\'m sure this is an extremely obvious question, and that there\'s a function that does exactly this, but I can\'t seem to find it. In PHP, I\'d like to know if my array has
I know you are not after array_unique(). However, you will not find a magical obvious function nor will writing one be faster than making use of the native functions.
I propose:
function array_has_dupes($array) {
// streamline per @Felix
return count($array) !== count(array_unique($array));
}
Adjust the second parameter of array_unique() to meet your comparison needs.