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。这里是每个里面都包含的,才取出它来 展开
重复值为2。这里是每个里面都包含的,才取出它来 展开
2个回答
展开全部
$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
)
)
)
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
)
)
)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$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
)
)
)
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
)
)
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询