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.
Advertisement
Here is an sample example:
1 2 3 4 5 6 7 | <?php $input = array("a" => "green", "green", "blue", "b" => "green", "red"); // Remove duplicate elements from an array $result = array_unique($array); print_r($result); ?> |
Expected output:
Array ( [a] => green [1] => blue [2] => red )