I have an array with several entries.
A common key inside is "date_timestamp"
Lets pretend this array is called $items
How do i organise the elements inside $items by the common key "date_timestamp" which is a unix time stamp?
Sorting an array by a key
Re: Sorting an array by a key
If you are reading the array of entries from a database, you can use "ORDER BY" (MySQL command) to sort entries based on date. Other than that, you can give ksort() function a try. Can't give specific answer without seeing your code.
Re: Sorting an array by a key
^ The best ideanyo wrote:If you are reading the array of entries from a database, you can use "ORDER BY" (MySQL command) to sort entries based on date
If you are stuck with the array as it is though you could try a usort() but it really depends on the format of it.