PHP array_unique function :- A php function which removes duplicate values from an array.

The array_unique() function removes duplicate values from given array. If two or more array values are the same, the first value will be kept and the other will be removed from that array.

Example 1 :-

echo "<pre>";
echo "</pre>";

Output :-

    [x] => Sunday
    [y] => Monday
    [z] => Tuesday

Example 2 :-

$input = array(11, "11", "4", 4, 11, "4");
$result = array_unique($input);
echo "<pre>";
echo "</pre>";

Output :-
array(2) {
  string(1) "4"

It will return 11 as an integer value & 4 as a string value.

I like to hear from you about this !!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.