this is my array:
$myarr = array(
4 => 3,
2 => 9,
7 => 8,
1 => 1
);
when i do :
asort($myarr);
$myarr becomes:
array(
1 => 1,
2 => 9,
4 => 3,
7 => 8
);
This is not how it is supposed to work,right? the values should be sorted and keys maintained, while the reverse is happening - just like ksort. What can the problem be?
Please help me out.
Thanks
Works fine to me : http://codepad.org/o6pZ8ess
result :
array(4) {
[1]=>
int(1)
[4]=>
int(3)
[7]=>
int(8)
[2]=>
int(9)
}
Works fine for me, did you try:
asort($myarr, SORT_NUMERIC);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With