Created
May 5, 2013 19:56
-
-
Save MattSurabian/5521979 to your computer and use it in GitHub Desktop.
A gist demonstrating a faster method to unique arrays in PHP. Embeded on my blog: http://mattsurabian.github.io/PHP/a-better-way-to-unique-arrays-in-php/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// array_unique is WAY TOO SLOW! This method is significantly faster. | |
array_flip(array_flip($arr)); | |
// If you need new keys generated use array_keys | |
array_keys(array_flip($arr)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment