Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

Possible Duplicate:
How to remove duplicate values from an array in PHP

How can I remove all multiple values for example 55,55 will only be 55 using PHP

Example 1

Array
(
    [0] => 9
    [1] => 2
    [2] => 55
    [3] => 55
    [4] => 9
)

Example 1 should look like example 2 below.

Array
(
    [0] => 9
    [1] => 2
    [2] => 55
)
share|improve this question

marked as duplicate by Gordon, Wrikken, Felix Kling, codaddict, Graviton Oct 17 '10 at 7:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
duplicate of How to remove duplicate values from an array in PHP – Gordon Oct 16 '10 at 20:56

1 Answer 1

up vote 7 down vote accepted

Use array_unique:

$a2 = array_unique($a);
share|improve this answer
1  
You're TWO seconds faster!!! – BoltClock Oct 16 '10 at 20:53
    
Arg, 12 seconds for me :/ – Anthony Forloney Oct 16 '10 at 20:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.