Multidimensional array sort by date |
[eluser]aniketharshe20[/eluser]
Hello, I want to sort multidimensional array by date with descending order. How to do it?? This my array: Code: Array --------------------------------------------- Thanks, Aniket
[eluser]jprateragg[/eluser]
I would sort it by date in your model/database query.
[eluser]PhilTem[/eluser]
Either you do what @jprateragg suggests, or you have a look at http://php.net/manual/en/array.sorting.php and the mentioned functions for some of which you can define a custom search function that compares the added_date however you define i.e. want to compare it ![]()
[eluser]aniketharshe20[/eluser]
Hi, I have mereged 2 arrays thats why they are not in order by date. I tried using array_multisort() but coudn't do it. Thanks, Aniket
[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) |
Welcome Guest, Not a member yet? Register Sign In |