PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

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
)

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 to point internal pointer to first element of an array?

I want to invert my value in array how can I do this?

how a values entered in an array from keyboard?

How can I loop through the members of an array?

How do I add to the end of an array and know how large the array is?



Custom Search