php - How can i sort after the newest date in my array? -
how can sort after newest date in array?
this output of array ($testarray):
array ( [0] => array ( [created] => 16-02-13 20:41:56 [restaurant_id] => 64324 [title] => café blabla [city] => state k ) [1] => array ( [created] => 19-02-13 13:42:14 [restaurant_id] => 42132 [title] => chicos blabla [city] => state k ) [2] => array ( [created] => 17-02-13 19:41:30 [restaurant_id] => 51242 [title] => restaurant blabla [city] => state k ) [3] => array ( [created] => 18-02-13 16:42:12 [restaurant_id] => 64342 [title] => couloir blabla [city] => state s )
try :
<?php $arr=your array; $sort = array(); foreach($arr $k=>$v) { $sort['created'][$k] = $v['created']; } array_multisort($sort['created'], sort_desc, $arr); echo "<pre>"; print_r($arr); ?>
php arrays
No comments:
Post a Comment