[nycphp-talk] multi dimension array sort?
Hans Zaunere
zaunere at yahoo.com
Tue Jun 10 09:10:45 EDT 2003
--- Nestor Florez <nestorflorez at earthlink.net> wrote:
> PHP'ers,
>
> I have an array multi associative array
>
> row[#]['empname'][dept']['ssn']['location']
>
> I want display them in a list and I want theuser to click on the column
> name and I will sort it according to the column and then display the array.
>
> I have tried using uasort, asort, array_multisort and I am not able to make
> it work. Can anyone give me a hand on how to do than multi associative
> array sort.
array_multisort() is probably closest to what you want, but even that isn't
*really* what you want since it sorts the columns left to right. You may try
something like:
array_multisort($row['empname']);
To do exactly what you want, I'd highly recommend using a database - SQL's
ORDER BY is great, and probably faster in the long run :)
Otherwise, consider breaking the multidimensional array into montholithic
arrays, which may make them easier to work with, including use in
array_multisort(). Typically, hugely multidimensional arrays bring more
confusion than anything else :)
H
More information about the talk
mailing list