Php Array Unique Function

What is array_unique Function?

Explanation

The "array_unique" function removes duplicate values from an array.

Syntax:


array_unique(array)

In the above syntax "array" is the array from which the duplicate values are removed.

Example :


<?php
$b=array("a"=>"Orange","b"=>"Guava","c"=>"Guava");
print_r(array_unique($b));
?>
Result :

Array ( [a]=> Orange [b]=> Guava );

In the above example the duplicate value "Guava" is removed and its displayed only once.

PHP Topics


Ask Questions

Ask Question