Home  >  Q&A  >  body text

How to sort based on score in PHP

By looping through values, the name is obtained in $name['name']; $staff_n obtains the total score of the corresponding name;

$hbsz=array($name['name'], $staff_n);

Now output this $hbsz array var_dump($hbsz); The result is as follows;

array (size=2)

0 => string ' Yuan Yunzhong' (length=6) 1 => float 5250array (size=2) 0 => string 'Li Siyuan' (length=9) 1 => float 11000array (size=2) 0 => string 'Zhang Songtao' (length=9) 1 => float 750

Could you please give me some advice on how to sort the output results from high to low according to the scores?

That is

array (size=2) 0 => string 'Li Siyuan' (length=9) 1 => float 11000

Ranked first

袁郡袁郡1291 days ago867

reply all(1)I'll reply

  • 不喜欢吃糖

    不喜欢吃糖2021-05-07 16:35:31

    Use rsort

    reply
    0
  • Cancelreply