Jump to content

group directory listing by file stat year then month


andyp7

Recommended Posts

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,

regards

Andy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.