SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Php

  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php

    How do you remove duplicate values from an array?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    array_unique — Removes duplicate values from an array
    http://us.php.net/array_unique

  3. #3
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As an aside, I've found using array_unique on very large arrays to take too long.

    I find it's faster to store the value as the key of the array, too, which prevents duplicates and is faster in my testing.

    instead of:

    $arr[] = 5;

    do

    $arr[5] = 5;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •