PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do you remove duplicate values from an array?


Duplicate values are easily removed using the array_unique function:

<?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?