How to use array unique in PHP
In this article, I will explain how the array_unique() function can be used in PHP.
array_unique() function in PHP
-
The array_unique() function removes duplicate values from an array.
-
the first value will be kept and the other will be removed, If two or more array values are the same, .
Syntax
Parameter
Example
The following example show to how the array_unique() function can be used in PHP.
<html>
<body>
<h3 style="color: saddlebrown;">array_unique() function example in PHP</h3>
<?php
$a = array("a" => "Nitin", "Ravi", "b" => "Nitin", "Rajesh", "Richa");
$result = array_unique($a);
print_r($result);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here