开发者

PHP sorting arrays numerically by key value descending [duplicate]

开发者 https://www.devze.com 2023-04-12 23:41 出处:网络
This question already has answers here: Sort array by numeric keys (4 answers) 开发者_开发知识库
This question already has answers here: Sort array by numeric keys (4 answers) 开发者_开发知识库 Closed last month.

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


Yes, the krsort

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


I believe krsort() is what you're looking for.


http://www.php.net/manual/en/function.krsort.php krsort?

0

精彩评论

暂无评论...
验证码 换一张
取 消