How can we remove duplicate value from an array in php?

Last updated 5 years, 1 month ago | 1382 views 75     5

Tags:- PHP

PHP | Remove duplicate value from an array 

Duplicate value can remove from an array by using the array_unique function. If two or more array values are the same, the first appearance will be kept and the other will be removed. It takes an input array and returns a new array without duplicate values.



	$a=array("a"=>"red","b"=>"blue","c"=>"green", "d"=>"red");



// output

Array ( 
    [a] => red 
    [b] => blue
    [c] => green