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:
If you want to only leave values in the array that are already unique, rather than select one unique instance of each value, you will indeed have to roll your own. Built in functionality is just there to sanitise value sets, rather than filter.