無論數值的位置,我做array_search時,數組鍵總是輸出'1',請問我該如何糾正? 的「174」敵人例如array_search應該輸出4爲重點無法獲取陣列鍵
<?php
$sid = $this->db->get_where('student' , array('class_id' => $class_id))->result_array();
/** Get Mark of Each Student **/
foreach($sid as $rowm){
$class_pos = $this->crud_model->get_exam_total($row2['exam_id'] , $class_id , $rowm['student_id']);
foreach($class_pos as $keys => $class_posi){
$arr = $class_posi['mark_obtained'];
$arra = array($keys + 1=> $arr);
$resulte = array_search(174, $arra);
?>
<td style="text-align: center;"><?php echo $resulte; ?></td>
<?php }}?>
您還可以接受的答案,如果那種出了問題,對未來用戶很有用 –