更新时间:2022-02-20 21:58:51
您可以创建领域的所有可能值的一小阵 A
使用的 array_map()
,从中抓住所有唯一值与的 array_unique()
,然后使用与原阵列相交它 array_intersect_key()
。
You can create a small array of all possible values of field a
using array_map()
, grab all unique values from it with array_unique()
and then intersect it with the original array using array_intersect_key()
.
$output = array_intersect_key(
$result,
array_unique(array_map(function($item) {
return $item['a'];
}, $result))
);
或者,由于5.5:
Or, since 5.5:
$output = array_intersect_key($result, array_unique(array_column($result, 'a')));