![](http://www.studyzone4u.com/assets/image/ads6.jpg)
How can we remove duplicate value from an array in php?
Last updated 5 years, 3 months ago | 1605 views 75 5
![](/media/uploads/2020/11/28/sz4u-cover-php.jpg)
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.
array_unique(array)
<?php
$a=array("a"=>"red","b"=>"blue","c"=>"green", "d"=>"red");
print_r(array_unique($a));
?>
// output
Array (
[a] => red
[b] => blue
[c] => green
)