How to remove duplicate values from an array in PHP

后端 未结 24 1874
故里飘歌
故里飘歌 2020-11-22 03:40

How can I remove duplicate values from an array in PHP?

24条回答
  •  天涯浪人
    2020-11-22 04:17

    The only thing which worked for me is:

    $array = array_unique($array, SORT_REGULAR);
    

    Edit : SORT_REGULAR keeps the same order of the original array.

提交回复
热议问题