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 find the size of an array?How do I sort the members of an array by value?
I have an array of numbers and many repeat, how to list all items in order of maximum occurence?
How do I remove the first element from an array?
How to get most repeated value in an array?
