dsh77114 2017-08-30 04:47
浏览 48

从嵌套数组中删除重复值

I have duplicated record from in my array as follow

   Array ( [0] => 
              Array ( 
                [driverId] => 112 
                [amount] => 15 
                [firstname] => Katty 
                )
           [1]=>
              Array ( 
                [driverId] => 112 
                [amount] => 15 
                [firstname] => Katty 
                )
           [2]=>
              Array ( 
                [driverId] => 118 
                [amount] => 15 
                [firstname] => Starkj 
                )
)

I want to remove with driverId so that my array will not have duplicated result. I tried with array_unique but it is unsuccessful. How can i achieve this ?

  • 写回答

2条回答 默认 最新

  • dongmi4809 2017-08-30 04:52
    关注

    Got it from a post

    $priceList= array_map("unserialize", array_unique(array_map("serialize", $priceList)));
    

    Hope it will help.

    评论

报告相同问题?