时间:2021-07-01 10:21:17 帮助过:9人阅读
//注册信息
$array1 = array(
0=>array(
'day'=>'2014-3-7',//注册日期
'data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000002'),
3=>array('uid'=>'0000003'),
4=>array('uid'=>'0000004'),
)
),
1=>array(
'day'=>'2014-3-8',//注册日期
'data'=>array(
0=>array('uid'=>'0000005'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000006'),
)
),
2=>array(
'day'=>'2014-3-10',//注册日期
'data'=>array(
0=>array('uid'=>'0000008'),
1=>array('uid'=>'0000010'),
2=>array('uid'=>'0000009'),
3=>array('uid'=>'0000012'),
4=>array('uid'=>'0000013'),
)
),
3=>array(
'day'=>'2014-3-11',//注册日期
'data'=>array(
0=>array('uid'=>'0000015'),
1=>array('uid'=>'0000014'),
2=>array('uid'=>'0000025'),
3=>array('uid'=>'0000017'),
4=>array('uid'=>'0000018'),
)
),
);
//登录日志
$array2 = array(
0=>array(
'day'=>'2014-3-8',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000002'),
3=>array('uid'=>'0000003')
)
),
1=>array(
'day'=>'2014-3-9',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000002'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000006'),
)
),
2=>array(
'day'=>'2014-3-11',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000008'),
3=>array('uid'=>'0000012'),
4=>array('uid'=>'0000013'),
5=>array('uid'=>'0000003'),
6=>array('uid'=>'0000002')
)
)
);
//注册信息
$array1 = array(
0=>array(
'day'=>'2014-3-7',//注册日期
'data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000002'),
3=>array('uid'=>'0000003'),
4=>array('uid'=>'0000004'),
)
),
1=>array(
'day'=>'2014-3-8',//注册日期
'data'=>array(
0=>array('uid'=>'0000005'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000006'),
)
),
2=>array(
'day'=>'2014-3-10',//注册日期
'data'=>array(
0=>array('uid'=>'0000008'),
1=>array('uid'=>'0000010'),
2=>array('uid'=>'0000009'),
3=>array('uid'=>'0000012'),
4=>array('uid'=>'0000013'),
)
),
3=>array(
'day'=>'2014-3-11',//注册日期
'data'=>array(
0=>array('uid'=>'0000015'),
1=>array('uid'=>'0000014'),
2=>array('uid'=>'0000025'),
3=>array('uid'=>'0000017'),
4=>array('uid'=>'0000018'),
)
),
);
//登录日志
$array2 = array(
0=>array(
'day'=>'2014-3-8',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000002'),
3=>array('uid'=>'0000003')
)
),
1=>array(
'day'=>'2014-3-9',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000002'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000006'),
)
),
2=>array(
'day'=>'2014-3-11',//登录日期
'ge_data'=>array(
0=>array('uid'=>'0000001'),
1=>array('uid'=>'0000007'),
2=>array('uid'=>'0000008'),
3=>array('uid'=>'0000012'),
4=>array('uid'=>'0000013'),
5=>array('uid'=>'0000003'),
6=>array('uid'=>'0000002')
)
)
);
$res = array();
//读取每天的注册记录
foreach($array1 as $r) {
$day = $r['day'];
$res[$day] = array('day' => $day, 'count' => count($r['data']));
$d = date('z', strtotime($day));
//对于当日注册每个用户
foreach($r['data'] as $us) {
foreach($array2 as $t) {
$rd = date('z', strtotime($t['day']));
//检查他在哪天登录了
foreach($t['ge_data'] as $u) {
if($us['uid'] == $u['uid']) $res[$day]['day_'.($rd-$d)][] = $us['uid']; //保存登录的uid以便于检查
}
}
}
}
print_r($res);
Array
(
[2014-3-7] => Array
(
[day] => 2014-3-7
[count] => 4
[day_1] => Array
(
[0] => 0000001
[1] => 0000002