如何删除一列中具有相同值的php数组中的记录

时间:2019-11-21 22:22:18

标签: php arrays

我有一个低于2D的阵列。我想从数组中删除重复的记录,因为它们具有与12345相同的“ EmployeeId”。这些记录的其他列可以具有不同的值。我尝试了array_unique()。但是,它需要所有值都相同。

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
        )
)

输出应为

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

提前谢谢!

0 个答案:

没有答案