当我添加htmlspecialchars_decode以阅读法文字母时,它与主代码冲突,并且我无法登录包含该报告的考试标记,它返回同一页>>>有人告诉我($ key和$ value)是定义了两次,如果正确的话我怎么写代码
function marks($id){
if(!$this->panelInit->can( "onlineExams.showMarks" )){
exit;
}
$return = array();
$exam = \online_exams::where('id',$id)->first();
$return['examDegreeSuccess'] = $exam->examDegreeSuccess;
$return['grade'] = \DB::table('online_exams_grades')
->where('examId',$id)
->leftJoin('users', 'users.id', '=', 'online_exams_grades.studentId')
->select('online_exams_grades.id as id',
'online_exams_grades.examGrade as examGrade',
'online_exams_grades.examDate as examDate',
'online_exams_grades.examQuestionsAnswers as examQuestionsAnswers',
'users.fullName as fullName',
'users.id as studentId')
->get();
foreach ($return['grade'] as $key => $value) {
$return['grade'][$key]->examQuestionsAnswers = json_decode($return['grade'][$key]->examQuestionsAnswers,true);
if(is_array($return['grade'][$key]->examQuestionsAnswers)){
foreach ($return['grade'][$key]->examQuestionsAnswers as $key => $value) {
$return['grade'][$key]->examQuestionsAnswers[$key]['title'] = strip_tags(htmlspecialchars_decode( $return['grade'][$key]->examQuestionsAnswers[$key]['title'] ));
}
}
$return['grade'][$key]->examDate = $this->panelInit->unix_to_date($return['grade'][$key]->examDate);
}
return json_encode($return);
}