Re: Sorting a multidimensional array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for that - can't do that as all I know in the database is the start
and end date for each event (so I don't have to create mapping tables and
perform massive joins), the rest is handle dynamically.

I think I can do it using usort, this seems to work, any comments?

function compare($x, $y) {

        if (($x['date'] == $y['date']) && ($x['start_time'] ==
$y['start_time'])) {
       return 0;
       } else if (($x['date'] == $y['date']) && ($x['start_time'] <
$y['start_time'])) {
       return -1;
       } else if (($x['date'] == $y['date']) && ($x['start_time'] >
$y['start_time'])) {
       return 1;
       } else if ($x['date'] < $y['date']) {
         return -1;
        } else {
         return 1;
       }
   }

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux