array_unique:
It takes an input array and returns a new array with no duplicate values.
Please note that the keys are saved. array_unique () first sorts the values processed as a string, and then saves the first key for each value and ignores all of the following keys.
you can try this to get the result:
<?php $input = array("a" => "green", 3=>"red", "b" => "green", 1=>"blue", "red"); print_r($input); $result = array_unique($input); print_r($result); asort($result); print_r($result);
source share