• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multidimensional array sort by date

#6
[eluser]pickupman[/eluser]
@jprateragg has the best of doing it in the model, provided that a UNION will work. Otherwise you can use [url="http://php.net/manual/en/function.usort.php"]ursort()[/url]. Here's a quick comparison function that will work on your array.
Code:
function sort_by_date($a, $b)
{
if ($a->added_date == $b->added_date)
{
  return 0;
}

return ($a->added_date < $b->added_date) ? -1 : 1;
}

usort($yourData, 'sort_by_date');


Messages In This Thread
Multidimensional array sort by date - by El Forum - 12-10-2012, 10:46 AM
Multidimensional array sort by date - by El Forum - 12-10-2012, 11:00 AM
Multidimensional array sort by date - by El Forum - 12-10-2012, 02:41 PM
Multidimensional array sort by date - by El Forum - 12-10-2012, 07:24 PM
Multidimensional array sort by date - by El Forum - 12-11-2012, 09:35 AM
Multidimensional array sort by date - by El Forum - 12-11-2012, 12:16 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.