Hallo! I have an associative array containing dates. here the code: $arr = array ("2009-03-11", "2009-06-22", "2007-04-14", "2009-04-14", "2009-04-15"); sort ($arr); echo "<pre>"; print_r ($arr); echo "</pre>"; PHP: It displays Array ( [0] => 2007-04-14 [1] => 2009-03-11 [2] => 2009-04-14 [3] => 2009-04-15 [4] => 2009-06-22 ) how to print the result in reverse chronologyБ 2009-06-22 2009-04-15 2009-04-14 2009-03-11 2007-04-14 HTML: Please help me Thanx!
Are you getting this list from a MySQL database, you can get them sorted there. You can also use arsort instead of sort.
These are things you should just look up on http://php.net - if you found http://php.net/asort you'd find in the related function section that there's also arsort: http://php.net/arsort which will sort an array in reverse order.
Um dude there's already a specific function for this as I said in the previous post, "arsort". There's no need to combine other functions to recreate the same behavior.
Well the example isn't an associative array, and it's also using a format for the dates that puts the most significant portion of the date first with a zero-fill in the lessor parts (YYYY-MM-DD), so "sort" or since you want reverse order, "rsort" will work.