Remove duplicate from array based on value?

Array
(
    [0] => Array
        (
            [country] => España
            [feature code] => PPLA3
            [country code] => ES
            [admin1code] => 51
            [admin2code] => H
            [town_province] => Beas
        )

    [1] => Array
        (
            [country] => España
            [feature code] => ADM3
            [country code] => ES
            [admin1code] => 51
            [admin2code] => H
            [town_province] => Beas
        )

)

How to remove only one of these! Notice values are always different!

I would like to do this:

  if there are 2 of these:  
 [country code] => ES
            [admin1code] => 51
            [admin2code] => H
            [town_province] => Beas

drop one!

you can do that with array_uintersect().

Could you PLS share some code maybe?

How would you apply this to my code please?

sorry, overestimated the array_intersect().

Any suggestions are very appreciated.

How to remove duplicates from here:

Array
(
    [España] => Array
        (
            [Provincia de Huelva] => Array
                (
                    [0] => Zufre
                    [1] => Zalamea la Real
                    [2] => Vista Alegre
                    [3] => Villarrasa
                    [4] => Villarrasa

define "duplicate" in three dimensions.

but for the first one you maybe use array_reduce() with a hash function that compares the appropriate keys on each iteration. its a question about what to do with the rest, e.g. random drop oder just group by.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.