Sort Multi Array in PHP -


does have idea how can sort array key (date) in php?

array (        [2011-02-16] => array         (             [date] => 2011-02-16             [num] => 2         )      [2011-02-11] => array         (             [date] => 2011-02-11             [num] => 0         )      [2011-02-17] => array         (             [date] => 2011-02-17             [num] => 0         )      [2011-02-18] => array         (             [date] => 2011-02-18             [num] => 0         )  ) 

use uasort function, user customizable sorting. this:

function cmp($a, $b) {     if ($a['date'] == $b['date'])     {         return 0;     }     return ($a['date'] < $b['date']) ? -1 : 1; }  uasort($your_array, "cmp"); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -