I know there is array_unique function, but I want to remove duplicates. Is there a built-in function or do I have to roll my own.
array_unique
Example input:
You can use a combination of array_unique, array_diff_assoc and array_diff:
array_diff($arr, array_diff_assoc($arr, array_unique($arr)))