PHP Array unique values

MyMomSaysIamSpecial picture MyMomSaysIamSpecial · May 3, 2013 · Viewed 30.2k times · Source

I have an array like this

Array
(
    [0] => Array
        (
            [id] => BA
            [name] => British Airways
        )

    [1] => Array
        (
            [id] => BA
            [name] => British Airways
        )

    [2] => Array
        (
            [id] => LA
            [name] => Lanchile
        )

    [3] => Array
        (
            [id] => LA
            [name] => Lanchile
        )

    [4] => Array
        (
            [id] => BA
            [name] => British Airways
        )

    [5] => Array
        (
            [id] => BA
            [name] => British Airways
        )

)

and i want to get

Array
(
    [0] => Array
        (
            [id] => BA
            [name] => British Airways
        )

    [1] => Array
        (
            [id] => LA
            [name] => Lanchile
        )
)

but after using array_unique function, all i have is

Array
(
    [0] => Array
        (
            [id] => BA
            [name] => British Airways
        )

)

what am i doing wrong?

Answer

diegoperini picture diegoperini · Jul 29, 2013
array_unique(my_array, SORT_REGULAR)

As requested in comments. :)