Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to remove duplicate key values in a Multidimensional array using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 384
    Comment on it

    Hello Reader's If you have an multidimensional array which you want to sort. Then PHP offers you many ways to do it.

    Let's see the easiest way to achieve it:-

    Array
    (
    [0] => Array
        (
            [0] => dave
            [1] => jones
            [2] => c@b.c
        )
    
    [1] => Array
        (
            [0] => john
            [1] => jones
            [2] => a@b.c
    
        )
    
    [2] => Array
        (
            [0] => bruce
            [1] => finkle
            [2] => c@b.c
        )
    )
    

    Now make the logic as below:-

    $newArr = array();
    foreach ($array as $val) {
        $newArr[$val[2]] = $val;    
    }
    $array = array_values($newArr);
    

 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: