I have an array of events… each event has a key called “time”. The “time” key stores a string such as “8:00 AM” or “6:00 PM”.
I need to order this array based on that time key. How would this be possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
strtotime()can parse things like8:00 AM. It is your friend.Note that if the array(s) you’re sorting in this fashion are very large, it may be worth it to store the value from
strtotime()as part of the array beforehand, to reduce the number of calls to it overall.