ginkworm
-
Posts
1 -
Joined
-
Last visited
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Sort a directory by filename only showing the latest file of each type based on the name
in PHP Coding Help
Posted
I have these files in a directory and can easily list to a webpage
Daily_CD_20130902.xml
Daily_CD_20130903.xml
Daily_CO_20130902.xml
Daily_CO_20130903.xml
Daily_CU_20130902.xml
Daily_CU_20130903.xml
Daily_EQ_20130902.xml
Daily_EQ_20130903.xml
Daily_IR_20130902.xml
Daily_IR_20130903.xml
However, i want to be selective and just select the most recent of each type, so instead of the whole list i want to display
Daily_CD_20130903.xml
Daily_CO_20130903.xml
Daily_CU_20130903.xml
Daily_EQ_20130903.xml
Daily_IR_20130903.xml
Is there an easy way to do this or do i need to take apart the filename, put the date in a date object and then use it to sort.
my current code is: