1
我有一個這樣的數組的數組:PHP的如何減少基於鍵的值
Array
(
[0] => Array
(
[CommodityID] => 10
[RetailerID] => 1798
[Name] => Petrol
[City] => Parow
[Line1] => 49 Fifth Avenue
[Line2] =>
[Line3] =>
[ContractorName] => BP Fifth Ave Motors Parow
[AreaCode] => 021
[Number] => 9305025
[Latitude] => -33.896493
[Longitude] => 18.579302
[LogoUrl] => https://webservices.test.com/ContractorLogos/bp.png
[dist] => 0.00
)
[1] => Array
(
[CommodityID] => 10
[RetailerID] => 1798
[Name] => Petrol
[City] => Parow
[Line1] => 49 Fifth Avenue
[Line2] =>
[Line3] =>
[ContractorName] => BP Fifth Ave Motors Parow
[AreaCode] => 021
[Number] => 9305025
[Latitude] => -33.896493
[Longitude] => 18.579302
[LogoUrl] => https://webservices.test.com/ContractorLogos/bp.png
[dist] => 0.00
)
[2] => Array
(
[CommodityID] => 22
[RetailerID] => 1758
[Name] => Jewellers
[City] => Parow
[Line1] => Shop 4
[Line2] => Mc Intyre Square
[Line3] => Mc Intyre Road
[ContractorName] => Du Plessis Manufacturing Jewellers Parow
[AreaCode] => 021
[Number] => 9300788
[Latitude] => -33.895200
[Longitude] => 18.586710
[LogoUrl] => https://webservices.test.com/ContractorLogos/DuPlessisJewellers.png
[dist] => 0.01
)
)
我只是想有隻獨特的[RetailerID]即:
Array
(
[0] => Array
(
[CommodityID] => 10
[RetailerID] => 1798
[Name] => Petrol
[City] => Parow
[Line1] => 49 Fifth Avenue
[Line2] =>
[Line3] =>
[ContractorName] => BP Fifth Ave Motors Parow
[AreaCode] => 021
[Number] => 9305025
[Latitude] => -33.896493
[Longitude] => 18.579302
[LogoUrl] => https://webservices.test.com/ContractorLogos/bp.png
[dist] => 0.00
)
[1] => Array
(
[CommodityID] => 22
[RetailerID] => 1758
[Name] => Jewellers
[City] => Parow
[Line1] => Shop 4
[Line2] => Mc Intyre Square
[Line3] => Mc Intyre Road
[ContractorName] => Du Plessis Manufacturing Jewellers Parow
[AreaCode] => 021
[Number] => 9300788
[Latitude] => -33.895200
[Longitude] => 18.586710
[LogoUrl] => https://webservices.test.com/ContractorLogos/DuPlessisJewellers.png
[dist] => 0.01
)
)
我有嘗試array_unique,但似乎基於所有列使其唯一。有沒有一個php內置函數可以通過查看一個數組鍵的值來實現?
可能重複:[https://stackoverflow.com/questions/6057151/multidimensional-array-unique-based-on-value- not-array-key](多維數組唯一基於值的非數組鍵) –
[多維數組基於值(不是數組鍵)唯一可能的副本](https://stackoverflow.com/questions/6057151/multidimensional-array-unique-based-value-not-array-key) –