Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Removing duplicate values from an array in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 120
    Comment on it

    Hello Readers,

    If we want to remove the duplicate values present in an array then their is a function named array_unique() that we can use .

    If two or more array values are the same, the first appearance value will be kept and the other will be removed.

    Example :

    <?php
    $a=array("a"=>"red","b"=>"green","c"=>"red");
    print_r(array_unique($a));
    ?>
    

    Output:

     Array ( [a] => red [b] => green ) 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: