I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible.
Example:
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))