jasonc Posted November 9, 2009 Share Posted November 9, 2009 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) 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.. $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. Link to comment https://forums.phpfreaks.com/topic/180841-list-files-from-folder-only-one-for-each-date/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.