public function gl_popular(){
$query=$this->db->query("SELECT DISTINCT new_ques_id FROM gl_mark_ques");
//echo "SELECT DISTINCT new_ques_id FROM gl_mark_ques" ."<br>";
if($query->num_rows > 0){
$question = array();
foreach($query->result() as $row){
$question[]=array(
'question'=>$row->new_ques_id,
'quest'=> $this->gl_avg_pop($row->new_ques_id),//tryin to sort according to this.
'get_quest'=>$this->gl_get_question($row->new_ques_id),
);
}
$av=array();
开发者_开发问答 //$av=asort($question[1]);
rsort($question[1]);
foreach ($question as $key => $val) {
echo "$key = $val\n";
}
//return $question;
//var_dump($av);
}
}
the problem is $question['quest']
gives me a floating point number. I need to store the array in such a way that highest floating point number will be first. Just not able to do it. Kindly help.
Have a look at array_multisort()
or, to make a bit more sense, add this to the query ORDER BY new_ques_id DESC
精彩评论