Why does array_unique sort the values?
问题 This refers to one of my previous questions: array_unique vs array_flip - This states that array_flip(array_flip()) is much quicker than array_unique() when dealing with simple strings and integers. What I would like to know is why array_unique() creates a copy of the array, sorts it then removed the duplicates The source for both functions is available here. Thanks in advance! 回答1: If you think about it algorithmically, the way to remove duplicates is to go through a list, keep track of