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
jsgouldAsked:
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
0
 
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.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

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.
0
 
jsgouldAuthor Commented:
Ray:
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.
Ciao!
0
 
Ray PaseurCommented:
Why did you give a marked-down grade?  Why not just post your solution and accept that as the answer?
http://support.experts-exchange.com/customer/portal/articles/481419
0
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.