Reputation: 91
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 in ascending order by date , i used asort() but didn't work
Upvotes: 1
Views: 1851
Reputation: 287755
usort($ar['comment'], function($v1, $v2) {
return $v1['date'] - $v2['date'];
});
In php<5.3, use create_function instead of the anonymous function notation.
Upvotes: 5
Reputation: 9562
I haven't tested, but something like this:
uasort($comment, function ($a, $b) { return $a['date'] - $b['date']; } );
Upvotes: 0