PHP sort an array on "Last Modified Date" with multiple dates the same error

I am producing a web page with a list of miscellaneous PDF documents. I want the list to be ordered by the last modified date in descending order. The problem I have is that some of the documents end up with the same time stamp. Apparently, PHP converts these time stamps into a number key for sorting and cannot deal with duplicates and items are dropped. I'm not a PHP guru so not sure how to deal with this
Who is Participating?
Ray PaseurCommented:
Sorry, I don't have windows files with Last Modified Date information.  How do you get this information?  Is it in an array, for example?  If so, you can print the array with var_export() and post that information in the code snippet here.  Once we see the format and content of the data set, it will be a snap to give you a tested and working code sample that sorts the array.

OTOH, if you're already satisfied with your own results, you can post those here and accept your own solution as the answer. Then others who have a similar issue can learn from your research!

Best regards, ~Ray
Ray PaseurCommented:
We need some more information to help you here -- specifically the test data set. (SSCCE)

To understand how PHP works with DATETIME values, please read this article, carefully for understanding.  It's amazingly easy once you understand the details.

PHP does not have anything inherent that can cause timestamps to be duplicates or cause items to be dropped.  There are standard programming practices that can prevent these sorts of problems.  Once we see the test data set, we can show you easy and dependable ways forward.
jsgouldAuthor Commented:
you really don't need any test data. The issue is based on the windows file "Last Modified Date" of any document(s).
if you are interested in the issue, Take any number of documents with the exact same last modified date and sort them in an array in descending order.

if not I will be happy to award you all of the points since you are the first (and only) respondent.

Actually I solved the issue by creating a unique key from the date to ensure no dups.
Ray PaseurCommented:
Why did you give a marked-down grade?  Why not just post your solution and accept that as the answer?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.