williamcarswell
williamcarswell

Reputation: 673

PHP sorting arrays numerically by key value descending

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

Upvotes: 11

Views: 15511

Answers (3)

xdazz
xdazz

Reputation: 160833

Yes, the krsort

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

Upvotes: 22

Alex
Alex

Reputation: 7374

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

Upvotes: 2

Franz
Franz

Reputation: 11553

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

Upvotes: 3

Related Questions