PHP sorting arrays numerically by key value descending

前端 未结 3 1669
执念已碎
执念已碎 2021-01-11 14:15

Is there an option in PHP to sort an array by key value descending?

I am aware that you can sort key values with ksort

3条回答
  •  自闭症患者
    2021-01-11 14:53

    Yes, the krsort

    $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
    krsort($fruits);
    

提交回复
热议问题