list files from folder, only one for each date


Posted on 16th Feb 2014 07:03 pm by admin

I have many files in a folder and wish to only list one of each date

these are the file names.
date format (dd/mm/yyy)
Did you know?Explore Trending and Topic pages for more stories like this.

abc - 12-01-2009 - something.pdf
abc - 12-01-2009 - something else.pdf
abc - 12-01-2009 - another title.pdf
abc - 24-05-2009 - some other text
abc - 24-05-2009 - yet more files
abc - 24-05-2009 - yet another title.pdf

if i had these files then i would like the results to be

12-01-2009
24-05-2009

in an array


at present i have this script..

Code: $files = glob('agendas/*.pdf');
$sortfile = array();
foreach($files as $file){
//Extract date
if (preg_match('/(d+)-(d+)-(d+)[^.]*?.pdf/', $file, $reg)) {
//if (preg_match('/(d+)-(d+)-(d+)-Agenda Item (d+)[^.]*?.pdf/', $file, $reg)) {
//add date to array (file as key)
$sortfile[$file] = mktime(0,0,0,$reg[2],$reg[1],$reg[3]);
}
}

this only gets the files but i would like to have these files sorted and have only one of each date

how would this be done.
No comments posted yet

Your Answer:

Login to answer
311 Like 42 Dislike
Previous forums Next forums
Other forums

socket communication between c++/java and sending image
hi,

i have a class in c++ called win32_sockserver which creates socket to java. i am trying

Problem with array max size.
Hi to everyone,
I've got a homework about filling a bidimensional array un spiral shape, I alre

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Linking with Foreign Keys
I have been getting an erro when I try and link:

create table Faculty_Specialty (I_Name v

Problem with HTML form
Hello,

I made a HTML form with some fields and check box.
Everything works fine except whe

images aren't rendering
I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder). The imag

Image DPI
Hi.

I allow users to upload images, the user then is able to adjust several settings for the

Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro

Slashes
Have a small problem and I'm not able to understand why I'm getting the results I'm getting... and i

Where is my php.ini???
Hi

First off - apologies - i'm not a coder so this may sound very amateur.

I'm having

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash