php - Best way to sort a big array by a key -


i have big array lots of datas, here can have example :

enter image description here

is example have 1 item [0].

i need sort array key date in last_message. (more in first)

in date have format : "2014-04-23t14:59:53+0200"

do have idea me ? don't want foreach think there better.

thanks !

this code :

uasort($arrayc, function ($a, $b) {             if ($a == $b) {                 return 0;             }             return (strtotime($a['last_message']->date) < strtotime($b['last_message']->date)) ? -1 : 1;         }); 

but there no effect on array..

you can use http://www.php.net/manual/en/function.uasort.php , provide custom function compares date.

this this:

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

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -