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

Setting a default timezone?
I have read about how to change the timezone in PHPMYADMIN, but it changes back, it doesn't STAY the

difference between datetimes
($row['totime']-$row['fromtime'])/60

this is giving me 0

example of totime and fromtim

issues verifying if user is logged in
I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to com

Reduce redundancies in switch functions?
Hello all! I somewhat new to PHP, and was wondering if anyone could give some suggestions on a swit

How to display objects in a row
I have 7 codes that i want to display in a row one next to another.
The first is {$ads->ad

Multiple WHILE loops help
Hi there. I'm writing an application that is pulling and displaying results for real estate listing

SAP BCS. BPS
Hi all,

I am seeking reading note on the following in BW

BCS, BPS
ADVANCE

A href problem under php
Hello...

I tried to explain the issue in an earlier post.. but was not clear enough....

Accept only alpha characters
I've got this bit of code ready for accepting a phrase:

Code: if (!eregi ("", $_POS

Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '

Code: [Select]preg_

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