php: alphabetically sort multi-dimensional array by it's key?
I'm trying to do the exact same thing as the guy in the thread above me. But my ksort($array) seems to return a number 1. What am I doing wrong?
php: alphabetically sort multi-dimensional array by it's key? I'm trying to do the exact same thing as the guy in the thread above me. But my ksort($array) seems to return a number 1. What am I doing wrong? |
|||||||
|
Have a look at the manual:
You see, ksort returns a boolean value, and directly works on the given array (note the reference sign
instead of, just:
|
|||
|
The function does in-place sorting, the function return TRUE on success or FALSE on failure. Refer to example from http://php.net/manual/en/function.ksort.php
The sorted result is in the variable $fruits, not from the function's return value. If you try print_r($fruits), you will get the result like this
|
|||
|
It doesn't literally return an 1, it returns true:
|
|||
|