php取出多维数组重复的值

全部有重复,如数组:Array([0]=>2[1]=>6)--Array([0]=>2[1]=>7)--Array([0]=>2[1]=>7)重复值为2。这里是每个里面都... 全部有重复,如数组:Array ( [0] => 2 [1] => 6 ) --Array ( [0] => 2 [1] => 7 ) --Array ( [0] => 2 [1] => 7 )
重复值为2。这里是每个里面都包含的,才取出它来
展开
 我来答
山水阿锐
2015-06-15 · TA获得超过34.3万个赞
知道顶级答主
回答量:23.7万
采纳率:91%
帮助的人:3.3亿
展开全部
$arr = array(
array(
array(
"stocknotifyId" => 1,
"sku" => '13809_BL_37',
"email" => 'huang@aaa.com'
),
array(
"stocknotifyId" => 3,
"sku" => '13809_BL_37',
"email" => 'hrheve@dfwef.com'
),
array(
"stocknotifyId" => 5,
"sku" => '13809_BL_37',
"email" => 'dfsfs@dfsf.com'
)
),
array(
array(
"stocknotifyId" => 2,
"sku" => '13809_B_39',
"email" => 'huang@aaa.com'
)
),
array(
array(
"stocknotifyId" => 4,
"sku" => '13809_BL_39',
"email" =>'hrheve@dfwef.com'
)
)
);

$re = array();

foreach($arr as $a) {
foreach ($a as $v) {
$tmp_v = $v;
unset($tmp_v['email']);
if(isset($re[$v['email']])) {
$re[$v['email']][] = $tmp_v;
}else{
$re[$v['email']] = array($tmp_v);
}

}
}

print_r($re);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

<!-- output -->
Array
(
[huang@aaa.com] => Array
(
[0] => Array
(
[stocknotifyId] => 1
[sku] => 13809_BL_37
)
[1] => Array
(
[stocknotifyId] => 2
[sku] => 13809_B_39
)
)
[hrheve@dfwef.com] => Array
(
[0] => Array
(
[stocknotifyId] => 3
[sku] => 13809_BL_37
)
[1] => Array
(
[stocknotifyId] => 4
[sku] => 13809_BL_39
)
)
[dfsfs@dfsf.com] => Array
(
[0] => Array
(
[stocknotifyId] => 5
[sku] => 13809_BL_37
)
)
)
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
兰亭幽草
2016-01-27 · TA获得超过2946个赞
知道小有建树答主
回答量:1453
采纳率:46%
帮助的人:373万
展开全部
$arr = array(
array(
array(
"stocknotifyId" => 1,
"sku" => '13809_BL_37',
"email" => 'huang@aaa.com'
),
array(
"stocknotifyId" => 3,
"sku" => '13809_BL_37',
"email" => 'hrheve@dfwef.com'
),
array(
"stocknotifyId" => 5,
"sku" => '13809_BL_37',
"email" => 'dfsfs@dfsf.com'
)
),
array(
array(
"stocknotifyId" => 2,
"sku" => '13809_B_39',
"email" => 'huang@aaa.com'
)
),
array(
array(
"stocknotifyId" => 4,
"sku" => '13809_BL_39',
"email" =>'hrheve@dfwef.com'
)
)
);

$re = array();

foreach($arr as $a) {
foreach ($a as $v) {
$tmp_v = $v;
unset($tmp_v['email']);
if(isset($re[$v['email']])) {
$re[$v['email']][] = $tmp_v;
}else{
$re[$v['email']] = array($tmp_v);
}

}
}

print_r($re);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

<!-- output -->
Array
(
[huang@aaa.com] => Array
(
[0] => Array
(
[stocknotifyId] => 1
[sku] => 13809_BL_37
)
[1] => Array
(
[stocknotifyId] => 2
[sku] => 13809_B_39
)
)
[hrheve@dfwef.com] => Array
(
[0] => Array
(
[stocknotifyId] => 3
[sku] => 13809_BL_37
)
[1] => Array
(
[stocknotifyId] => 4
[sku] => 13809_BL_39
)
)
[dfsfs@dfsf.com] => Array
(
[0] => Array
(
[stocknotifyId] => 5
[sku] => 13809_BL_37
)
)
)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式