Been bugging me for a while.
Its just a little script to display the JPG and BMP files in a dir. But I just cannot get it to sort by filename
<?php
$main = ".";
$ftype1 = 'jpg';
$ftype2 = 'bmp';
$dir = opendir($main);
$j = 1;
while($filename = readdir($dir))
{
$ext = strpos($filename, $ftype1);
$ext2 = strpos($filename, $ftype2);
if ($ext == true || $ext2 == true)
{
echo '<td width="115" height="100"><a href="'.$filename.'"><img src="'.$filename.'" height="70" border="0" /></a><br />
<font size="2" face="tahoma" color=white>'.$filename.'<br /></font></td>';
if ( $j % 4 == 0 )
{
echo '</tr><tr>';
}
$j++;
}
}
closedir($dir);
exit;
?>
It does exactly what I want, except for the sort part
Any ideas? I have tried a bunch of different things but with no success.
Thanks!