Welcome Guest, Not a member yet? Register   Sign In
Please help, Iarray sort not working
#1

Hello. Please somebody help..I want to arrange the foreach loop according to the highest number of average exam score. 
I used rsort or sort array but it returns zero.
see my code:

<?php 
$this->db->where('class_id' , $class_id);
$this->db->where('year' , $running_year);
$this->db->from('subject');
$number_of_subjects = $this->db->count_all_results();
$average_score= ($total_marks / $number_of_subjects);
rsort($average_score);
echo(round($average_score,2));
?>
after i get the highest average score i want to rank it as 1st,2nd, 3rd....
Kindly help
Reply
#2

rsort requires an array. You appear to be trying to sort a single variable. https://www.php.net/manual/en/function.rsort.php
Reply




Theme © iAndrew 2016 - Forum software by © MyBB