How do you remove duplicate values from an array?
<?php
$values = array("banana","apple","pear","banana");
$values = array_unique($values);
print_r($values);
?>
Outputs:
Array
(
[0] => banana
[1] => apple
[2] => pear
)
Comments on this Question/Answer
How can i remove the duplicate values from the database fetched result?By: hussain, 11 Dec 2009 03:31:43
Reply to comments / post your own comment >>>
ASK A QUESTION
More arrays PHP Questions
How do I remove an element from an array without changing the index values for the rest of the array?How do I find if a value is already in an array or not?
How can I sort an array keeping the correlation between the index and value?
I am not interested in the values in the arrays, how can I discard them?
How can I create an array of numbers easily?
