krsort

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

krsort -- Sort an array by key in reverse order

Description

int krsort (array array [, int sort_flags])

Sorts an array by key in reverse order, maintaining key to data correlations. This is useful mainly for associative arrays.

Példa 1. Krsort() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 krsort ($fruits);
  4 reset ($fruits);
  5 while (list ($key, $val) = each ($fruits)) {
  6     echo "$key -> $val\n";
  7 }
  8       

This example would display:

  1 
  2 fruits[d] = lemon
  3 fruits[c] = apple
  4 fruits[b] = banana
  5 fruits[a] = orange
  6       

You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort().

See also asort(), arsort(), ksort() sort(), and rsort().