How can we remove duplicate value from an array in 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.
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
)