Here is a function to find duplicate items in an array.
[source language=“php“]
/**
* Takes an array and returns an array of duplicate items
*/
function get_duplicates( $array ) {
return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
}
[/source]

This is really great . I was looking for a fast solution to this problem and your solution works great.Nice job!!!
its good for new developers
but it dowsn’t work on multidimensional arrays… ^(((
this is great, it returns unique elements for any number of repeatables for any number.
ahh gotta love one liners
Still helping in 2018 ….:)
Its not working for associative array