Hey Everyone,
I’ve got a great dynamic image gallery going on my website and I was wondering if I could get some help sorting this array. I have it displaying all directories within a folder as links in a list. The folders for my albums are all following this naming structure: Month Year (ex. April 2006). Is there anyway to sort the array so I can break up the albums by year. For example I would have all albums with the word 2004 displayed within one <div> or <ul>. And then have all the albums with the word 2005 displayed in another <div> or <ul>. Here is the code I am using right now to display my folders.
[code=php]
<?php
$albumsDir=”ajax/albums/”;
function dirList ($directory){
$results = array();
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != ‘.’ && $file != ‘..’)
$results[] = $file;
}
closedir($handler);
return $results;
}
$photolist = (dirList(“./”.$albumsDir));
for ($i=0;$i<count($photolist);$i++)
echo “<li><a title=”$photolist[$i]” target=”iframemain” href=”http://www.giannaross.com/ajax/?album=”.$photolist[$i].””>”.$photolist[$i].”</a></li>n”;
?>