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
)
More arrays PHP Questions
How do I reverse the order of the elements in an array?How do I add to the end of an array and know how large the array is?
How do I add to the beginning of an array and find the number of elements in it?
How do I count the number of times a value appears in an array?
How do I write my own sort function?