Page 1 of 1

Sorting a multi-dimensional array by element

Posted: Thu Jul 28, 2005 5:06 am
by malcolmboston
example

Code: Select all

Array
(
    ї1] => Array
        (
            їid] => 1
            їname] => John
        )
    ї2] => Array
        (
            їid] => 2
            їname] => Roger
        )
    ї3] => Array
        (
            їid] => 3
            їname] => Adam
        )

)
short & sweet

how would you resort the array by name?

Posted: Thu Jul 28, 2005 5:29 am
by onion2k
usort()

You'll need to write a custom function to compare the elements. The PHP manual page on it is pretty easy to follow.