Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Building a gallery.

Name: Anonymous 2009-10-05 19:31

Is this the where I can cry about how terrible I am at PHP? :O

I am trying to make a gallery, and I would like the array to sort by the latest pictures added to be first on the list.

What I currently have working is:
if ($dirHandle = opendir($galleryDir)) {
    while (($file = readdir($dirHandle)) !== false) {
        if (isImage("$galleryDir/$file")) {
            $images[] = $file;
        }
    }
    closedir($dirHandle);
}
I figured readdir would let me make it so when I told the directory to sort by date, the gallery page would, such is not the case, it seems eternally alphabetical.

I was tinkering with:
function LoadFiles($dir)
{
 $Files = array();
 $dir          = "porn/images";
 $It =  opendir($dir);
 if (! $It)
  die('Cannot list files for ' . $dir);
 while ($Filename = readdir($It))
 {
  if ($Filename == '.' || $Filename == '..')
   continue;
  $LastModified = filemtime($dir . $Filename);
    $Files[] = array($dir .$Filename, $LastModified);
 }

  return $Files;
}
function DateCmp($a, $b)
{
  return ($a[1] < $b[1]) ? -1 : 0;
}

function SortByDate(&$Files)
{
  usort($Files, 'DateCmp');
}

$Files = LoadFiles('data/');
SortByDate($Files);

But I get Warning: filemtime() [function.filemtime]: stat failed for  file

Can anyone help me, perchance?  I am no good at computers, how did this cat get here? =(^.^)=

Thanks in advance~

Name: Anonymous 2009-10-05 19:35

Some people, when confronted with a problem, think
“I know, I'll use PHP.”   Now they have two problems.

Haskell is the right tool for this job.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List