11

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

0

3 Answers 3

22

Yes, the krsort

$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
krsort($fruits);
Sign up to request clarification or add additional context in comments.

Comments

3

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

1 Comment

Posting a hurried link to the documentation in after about sixty seconds of the ask time perfectly represents how FGITW answers were bad for Stack Overflow and its researchers during the early years. This answer lacks generosity.
2

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

1 Comment

Posting a hurried link to the documentation in after about sixty seconds of the ask time perfectly represents how FGITW answers were bad for Stack Overflow and its researchers during the early years. This answer lacks generosity.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.