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

how to get different value in second view of webdynpro?
hello guys,

In ABAP webdynpro I am trying to create one application having two views.

having a small php error tha deals with the 'foreach'
Last night i was working on a script for a cart and it seemed to working good, until this morning. F

Help with some dates
I have a list of dates in an array:

$mondays = array(
strtotime("October 12, 2009

Rounding a number queried from a database
I know that to display a rounded number you just do echo "round($number)";. But how would

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot

How can you detect variable string in a massive string?
Ok guys, i need some help with this one.

I am going to be getting a large string, like 10-20

Can I use a loop
Hi buddies!

Once again with my doubts here.

Right now I am using this sql stat

retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell

Pre-Fill out a PHP form...??
This is for work actually (geek squad). We have to fill out this online php form at work over and ov

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