Check and return duplicates array php
this will be ~100 times faster than array_diff
$dups = array();
foreach(array_count_values($arr) as $val => $c)
if($c > 1) $dups[] = $val;
You can get the difference of the original array and a copy without duplicates using array_unique
and array_diff_assoc
:
array_diff_assoc($arr, array_unique($arr))