0

I have a below 2D array. I want to remove duplicate records from array since they have the same 'EmployeeId' as 12345. These records can have different values for other columns. I tried array_unique(). However, it needs all the values to be the same.

Array
(
    [0] => Array
        (
            [EmployeeId] => 12345
            [FirstName] => John
            [LastName] => Smith
            [Age] => 30
        )

    [1] => Array
        (
            [EmployeeId] => 12345
            [FirstName] => Joe
            [LastName] => Marsh
            [Age] => 45
        )
    [2] => Array
        (
            [EmployeeId] => 45678
            [FirstName] => Ellie
            [LastName] => Smith
            [Age] => 78
        )
)

Output should be

Array
(
    [0] => Array
        (
            [EmployeeId] => 45678
            [FirstName] => Ellie
            [LastName] => Smith
            [Age] => 78
        )
)

Thank you in advance!

Adi
  • 405
  • 1
  • 7
  • 13

0 Answers0