If you to remove duplicate values from an array in PHP? Use array_unique()
to remove duplicate values from an array.
Parameter | Description |
---|---|
array | Required. Specifying an array |
sorttype | Optional. Specifies how to compare the array elements/items. Possible values:
|
PHP array_unique() function example
1 2 3 4 | <?php $a=array("a"=>"red","b"=>"green","c"=>"red"); print_r(array_unique($a)); ?> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.