※ 引述《LMGG (联盟GG)》之铭言:
$source = array(
0 => array
(
'people' => '0101001',
'place' => '001',
'type' => '01',
'time' => '2016-11-01 08:59:34'
),
1 => array
(
'empno' => '0101001',
'place' => '001',
'type' => '02',
'time' => '2016-11-01 18:06:06'
),
2 => array
(
'empno' => '0101002',
'place' => '001',
'type' => '02',
'time' => '2016-08-01 18:03:00'
),
3 => array
(
'empno' => '0101001',
'place' => '002',
'type' => '01',
'time' => '2016-08-02 09:06:58'
),
4 => array
(
'empno' => '0101001',
'place' => '004',
'type' => '02',
'time' => '2016-08-02 19:52:50'
)
);
$data = array();
foreach ($source as $row){
$date = date('Y-m-d', strtotime($row['time']));
$people = isset($row['people']) ? $row['people'] : $row['empno'];
$type = $row['type'];
$data["$people"]["$date"]["$type"] = $row['place'];
}
foreach ($data as $pi => $pd){
foreach ($pd as $di => $dd){
if(!isset($dd["01"]) || !isset($dd["02"])){
echo "people : $pi has an exception occurred at $di
".PHP_EOL;
}
}
}