Purpose:
Array_unique function gets only one parameter that is array. array_unique function remove duplicate values from an array. The duplicate value’s first occurrence is kept and other is truncated.
Code:
<?php
$name=array("T"=>"Tahreem","R"=>"Rizwan","A"=>"Anwar","D"=>"Rizwan");
print_r(array_unique($name));
?>
Output:
Array ( [T] => Tahreem [R] => Rizwan [A] => Anwar )
Explanation:
On line 2 we have declared an array $name and initialize it by values. Then pass it to array_unique function that removes duplicate values from it. On line 2 we have written value Rizwan two times so it removes one time by array_unique function. Then on line 3 we have passed it to print_r function that traverse entire array and print it.