Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Unique array

I have an array

    Array
    (
     [fbid] = Array
            (
                **[0] => 115637705237540
                [1] => 115637705237540**
                [2] => 111723238962320
                [3] => 111723248962319
                [4] => 112721842195793
                [5] => 112567698877874
                [6] => 111844022283575
                **[7] => 115637705237540**
                [8] => 111840252283952
                [9] => 109642909170353
            )

       [fb_parentid] = Array
            (
                [0] => 571228125
                [1] => 571228125
                [2] => 571228125
                [3] => 571228125
                [4] => 571228125
                [5] => 571228125
                [6] => 571228125
                [7] => 571228125
                [8] => 571228125
                [9] => 571228125
            )

)

Here 0 , 1 and 7 are repeating. First I want to get the repeating indexes (0,1,7). Second , I want to display one one index. In above example only 0th.

After that I want to remove 1 and 7 from [fb_parentid] and [fbid]

Can you help me ?


1 Answers

You're looking for the array_unique function.

$new_array = array_unique($old_array);
like image 135
Norse Avatar answered Sep 04 '26 06:09

Norse