Skip to content

How to Remove Duplicate Array Values in PHP

Advertisement

A Sample PHP script to remove all the duplicate values from an array. A running example to remove duplicate array values using PHP

Use PHP array_unique() function to remove all the duplicate values form an array. This function takes input of an array and return another array without duplicate values.

Here is an sample example:

Expected output:

Array
(
    [a] => green
    [1] => blue
    [2] => red
)

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top