this is my array
[comment] => Array
(
[0] => Array
(
[mem_id] => 51
[comment] => nice...
[profilenam] => xyz
[photo_thumb] => photos/81951b37ad01c4aa65662956f178214eth.jpeg
[date] => 1307975661
)
[1] => Array
(
[mem_id] => 329
[comment] => nice...
[profilenam] => abc
[photo_thumb] => photos/f841eab12f5a24ce12b984904760c05fth.jpeg
[date] => 1308043486
)
)
actually i wanted to arrange i开发者_Go百科n ascending order by date , i used asort() but didn't work
usort($ar['comment'], function($v1, $v2) {
return $v1['date'] - $v2['date'];
});
In php<5.3, use create_function instead of the anonymous function notation.
You are sorting array of array, in this case none of the built-in sort function with built-in comparison function would work. Try usort or uasort instead.
I haven't tested, but something like this:
uasort($comment, function ($a, $b) { return $a['date'] - $b['date']; } );
精彩评论