How to remove all instances of duplicated values from an array

前端 未结 9 1143
心在旅途
心在旅途 2021-01-02 19:48

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.

Example input:

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 20:21

    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.

提交回复
热议问题