Skip to content

Instantly share code, notes, and snippets.

@MattSurabian
Created May 5, 2013 19:56
Show Gist options
  • Save MattSurabian/5521979 to your computer and use it in GitHub Desktop.
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/
// 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