我有一个这样的数组,我需要得到唯一的关联索引
Array
(
[0] => Array
(
[id] => 200
[name] => james
[place] => ca
)
[1] => Array
(
[id] => 201
[name] => jana
[place] => uk
)
[2] => Array
(
[id] => 203
[name] => jana
[place] => ca
)
)
这意味着我需要从该数组中获取唯一的“位置”
英国,英国
最佳答案
利用array_column()
和 array_unique()
array_unique(array_column($array, 'place'))
- array_column — Return the values from a single column in the input array (PHP 5 >= 5.5.0, PHP 7)
- array_unique — Removes duplicate values from an array (PHP 4 >= 4.0.1, PHP 5, PHP 7)
关于php - 数组中的唯一关联索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46441422/