using asort function we can sort array values, it sorts the values only, it maintain the index association.
$countries = array(1=>'us', 2=>'ind', 3=>'canada') asort($countries) foreach($countries as $key=>$val) { echo "$key = $val \n"; }
o/p will be
3 = canada 2 = ind 1 = us
using asort function we can
Wed, 12/10/2008 - 21:35 — adminusing asort function we can sort array values, it sorts the values only, it maintain the index association.
$countries = array(1=>'us', 2=>'ind', 3=>'canada')
asort($countries)
foreach($countries as $key=>$val) {
echo "$key = $val \n";
}
o/p will be
3 = canada
2 = ind
1 = us