Array
(
[A] => 姓名
[B] => 考号
[C] => 班级
[D] => 原始分
[E] => 客观题得分
[F] => 主观题得分
[G] => 得分:01
[H] => 作答:01
[I] => 得分:02
[J] => 作答:02
[K] => 得分:03
[L] => 作答:03
[M] => 得分:04
[N] => 作答:04
[O] => 得分:05
[P] => 作答:05
[Q] => 得分:06
[R] => 作答:06
[S] => 得分:07
[T] => 作答:07
[U] => 得分:08
[V] => 作答:08
[W] => 得分:09
[X] => 作答:09
[Y] => 得分:10
[Z] => 作答:10
[AA] => 得分:11
[AB] => 作答:11
[AC] => 得分:12
[AD] => 作答:12
[AE] => 得分:13
[AF] => 作答:13
[AG] => 得分:14
[AH] => 作答:14
[AI] => 得分:15
[AJ] => 作答:15
[AK] => 得分:16
[AL] => 作答:16
[AM] => 得分:17
[AN] => 作答:17
[AO] => 得分:18
[AP] => 作答:18
[AQ] => 得分:19
[AR] => 作答:19
[AS] => 得分:20
[AT] => 作答:20
[AU] => 得分:21
[AV] => 作答:21
[AW] => 得分:22
[AX] => 作答:22
[AY] => 得分:23
[AZ] => 作答:23
[BA] => 得分:24
[BB] => 作答:24
[BC] => 得分:25
[BD] => 作答:25
[BE] => 得分:26
[BF] => 作答:26
[BG] => 得分:27
[BH] => 作答:27
[BI] => 得分:28
[BJ] => 作答:28
[BK] => 得分:29
[BL] => 作答:29
[BM] => 得分:30
[BN] => 作答:30
[BO] => 得分:31
[BP] => 作答:31
[BQ] => 得分:32
[BR] => 作答:32
[BS] => 得分:33
[BT] => 作答:33
[BU] => 得分:34
[BV] => 作答:34
[BW] => 得分:35
[BX] => 作答:35
[BY] => 得分:36
[BZ] => 作答:36
[CA] => 得分:37
[CB] => 作答:37
[CC] => 得分:38
[CD] => 作答:38
[CE] => 得分:39
[CF] => 作答:39
[CG] => 得分:40
[CH] => 作答:40
[CI] => 得分:41
[CJ] => 作答:41
[CK] => 得分:42
[CL] => 作答:42
[CM] => 得分:43
[CN] => 作答:43
[CO] => 得分:44
[CP] => 作答:44
[CQ] => 得分:45
[CR] => 作答:45
[CS] => 得分:46
[CT] => 作答:46
[CU] => 得分:47
[CV] => 作答:47
[CW] => 得分:48
[CX] => 作答:48
[CY] => 得分:49
[CZ] => 作答:49
[DA] => 得分:50
[DB] => 作答:50
[DC] => 得分:51
[DD] => 作答:51
[DE] => 得分:52
[DF] => 作答:52
[DG] => 得分:53
[DH] => 作答:53
[DI] => 得分:54
[DJ] => 作答:54
[DK] => 得分:55
[DL] => 作答:55
[DM] => 得分:56-65
[DN] => 得分:66
[DO] => 得分:67
)
$info = File::checkLocalFile($file_id,'studentScore');
if(file_exists($info['path']))
{
try {
$data = \moonland\phpexcel\Excel::widget([
'mode' => 'import',
'fileName' => $info['path'],
'setFirstRecordAsKeys' => false, // if you want to set the keys of record column with first record, if it not set, the header with use the alphabet column on excel.
'setIndexSheetByName' => true, // set this if your excel data with multiple worksheet, the index of array will be set with the sheet name. If this not set, the index will use numeric.
// 'getOnlySheet' => '校班级成绩表', // you can set this property if you want to get the specified sheet from the excel data with multiple worksheet.
]);
// 检查文件的下载时间,若超过2天,则删除临时处理文件
$fileTime = filemtime($info['path']);
$currentTime = time();
$oneDay = 24 * 60 * 60 * 2;
if ($currentTime - $fileTime > $oneDay) {
unlink($info['path']);
}
} catch (\Exception $e) {
// 如果处理失败,尝试直接导入原始文件
$data = \moonland\phpexcel\Excel::widget([
'mode' => 'import',
'fileName' => $info['path'],
'setFirstRecordAsKeys' => false,
'setIndexSheetByName' => true,
]);
}
$title = [];
$t = $data[2];
$keys = array_keys($t);
$values = array_values($t);
// foreach($values as $key => $value)
// {
// $t[$keys[$key]] = $value;
// }
// print_r($data[3])
//将$data[2]中的所有数据中的 (*)内容去除,比如: 01(满分1.5分,正确答案:A)修改为01
foreach($values as $key => $value)
{
$text = preg_replace('/\([^)]*\)/', '', $value);
$text = trim($text);
$m[$key] = $text;
// if($data[2][$key] == '')
// {
// $data[2][$key] = $data[2][$key-1] ?? '';
// }
if($text == '')
{
// $t[$keys[$key]] = $values[$key-1] ?? '';
$text = $m[$key-1] ?? '';
}
// print_r($keys[$key].'-'.$text."\r\n");
if($data[3][$keys[$key]] == '')
{
$t[$keys[$key]] = $text;
}
else
{
$t[$keys[$key]] = $data[3][$keys[$key]].':'.$text;
}
// $t[$keys[$key]] = $data[3][$keys[$key]].'-'.$text;
}
$title = $t;
//整合$t和$data[3]
// $t = array_merge($t, $data[3]);
print_r($t);