How to remove all instances of duplicated values from an array

前端 未结 9 1179
心在旅途
心在旅途 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条回答
  •  没有蜡笔的小新
    2021-01-02 20:24

    The answer on top looks great, but on a side note: if you ever want to eliminate duplicates but leave the first one, using array_flip twice would be a pretty simple way to do so. array_flip(array_flip(x))

提交回复
热议问题