phpsorting

Printing the return value from arsort() shows the number "1"


I am trying to sort an array in PHP and for some reason all I get in return is "1" when I attempt to use any of the sort() functions.

echo arsort($array);

All I get in return on the page is "1."

Any thoughts on what I am doing wrong?


Solution

  • Array sort() functions work on a reference of the array. As such they don't return the sorted array but true (1) or false (0).

    print_r($tag);
    arsort($tag);
    print_r($tag);