我有一个数组,我确定其中有一些重复的值,我想在这个数组中搜索并找到重复的值并返回该数组的键。
让我用一个例子来解释,这是我的数组:
[
0 => [
'name' => 'name0',
'family' => 'family0',
'email' => 'email0@sample.com',
'rate' => 10
],
1 => [
'name' => 'name1',
'family' => 'family1',
'email' => 'email1@sample.com',
'rate' => 4
],
2 => [
'name' => 'name0',
'family' => 'family0',
'email' => 'email0@sample.com',
'rate' => 6
]
];
现在,我想在这个数组中搜索name, family, 并email同时返回父项的键(在本例中为 0 和 2)。因为我想创建一个这样的新数组:
[
0 => [
'name' => 'name0',
'family' => 'family0',
'email' => 'email0@sample.com',
'rate' => [
10,
6
]
],
1 => [
'name' => 'name1',
'family' => 'family1',
'email' => 'email1@sample.com',
'rate' => [
4
]
],
];
我怎样才能在 PHP 中做到这一点?
ITMISS