I want to assign or store the values I get from foreach loop into an array, so that I can use array sort function for the values. Please below is my code. It seems to create a whole new array for every loop with key = 0. And if i place the print statement below the loop, it will display only the last value obtained from the loop. I don't understand how it was explained in This Question
<?php
$studen_id = $this->db->get_where('student' , array('class_id' => $class_id))->result_array();
foreach($studen_id as $row){
$mark_obtained = $this->crud_model->get_exam_total($row2['exam_id'] , $class_id , $row['student_id']);
$student_mark = array($mark_obtained);
// rsort($student_mark);
echo "<li>"; print_r($student_mark); echo "</li>";
}
?>