andyp7 Posted November 10, 2006 Share Posted November 10, 2006 I have a script that lists the contents of a directory. These are all system generated html files. At present they are just listed in descending date order. I would like to be able to group these into their years and months of creation. I will then use javascript to show\hide the relevent lists.Could someone help me with the code for taking the file list array and creating a associate array from this to achieve above, at present the code is[code]<div id="media_reports"> <ul> <li><span class="zrep" >Media Report</span><span class="zdate">Date created</span></li><?php foreach ($files as $file) { $filename = basename($file); $dirname = dirname($file); $href = $url.$club."/".$filename; $info = stat($file); $subdir = substr($dirname, strlen($dir.$club)+1, strlen($dirname)); if ($subdir != "") $subdir = $subdir."/";?> <li><span class="zrep"><a href="<?=$href;?>"><?=$subdir.$filename;?></a></span><span class="zdate"><?=date("d.M.Y H:i:s", $info[9]);?></span></li><?php }?> </ul></div>[/code]Any guidance much appreciated,regardsAndy Link to comment https://forums.phpfreaks.com/topic/26805-group-directory-listing-by-file-stat-year-then-month/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.