Sort an array by key using PHP

by sabitha 2012-06-05 16:41:31

Sort an array by key using PHP



$colors = array("d"=>"blue", "a"=>"green", "b"=>"red", "c"=>"magenta");
ksort($colors);
print_r($colors);

will outputs as
green
red
magenta
blue

Tagged in:

393
like
0
dislike
0
mail
flag

You must LOGIN to add comments