1

Hello guys i m new in php I have some multidimensional array like this

Array
(
    [0] => Array
        (
            [id] => 100
            [user_id] => 200
        )

    [1] => Array
        (

            [id] => 100
            [user_id] => 300
        )

    [2] => Array
        (

            [id] => 100
            [user_id] => 200
        )

    [3] => Array
        (
            [id] => 100
            [user_id] => 400
        )

    [4] => Array
        (
            [id] => 100
            [user_id] => 200
        )

)

I want to remove duplicate value like array[0] and array[2] and array[4] have. I mean i need my final output like this

Array
(
    [0] => Array
        (
            [id] => 100
            [user_id] => 200
        )

    [1] => Array
        (

            [id] => 100
            [user_id] => 300
        )

    [2] => Array
        (
            [id] => 100
            [user_id] => 400
        )
)

Please help to i don't know to how to do in php.

Dexter
  • 1,804
  • 4
  • 24
  • 53

1 Answers1

1

Use array_unique()

array_unique($array, SORT_REGULAR);
Pupil
  • 23,834
  • 6
  • 44
  • 66
  • 1
    It's working fine check [**this**](https://eval.in/446203) +1 – Narendrasingh Sisodia Oct 07 '15 at 12:32
  • 1
    @Pupil you've done fine work but its the duplicate answer which the OP can get it from just using simple [**search**](https://www.google.co.in/search?q=array_unique+on+multidimensional+arrays&oq=array_unique+on+multi&aqs=chrome.0.0j69i57j0l3.9499j0j7&client=ubuntu&sourceid=chrome&es_sm=93&ie=UTF-8) – Narendrasingh Sisodia Oct 07 '15 at 12:35
  • but waht if i have one more value in inside of array i mean like this [2] => Array ( [id] => 100 [user_id] => 400 [myvalue] => 4 ) – Dexter Oct 07 '15 at 12:39