"; //debug:
foreach ($pic_array as $mypic){
$file_ext = strstr($mypic,'.');
if($file_ext == ".jpg" || $file_ext ==".JPG") {
$nice_array[$n] = $mypic;
//echo "nice_array $n is $nice_array[$n]
\n"; //debug
$n = $n+1;
}
}
// Get number of items in array and the remainder when divided by 3
$num_files = count($nice_array);
$num_rows = floor($num_files/3);
$remainder = $num_files%3;
// This is for debugging only.
// echo "\n
"; // echo "Number of files: $num_files\n"; // echo "\n
";
// foreach ($pic_array as $mypic){
// echo "$mypic
";
// }
// Create a table of thumbnails 3 columns wide
echo "\n\n";
// Two FOR loops take care of the complete rows
for ($i=1; $i<=$num_rows; $i++) {
echo "\n";
for ($j=1; $j<=3; $j++) {
echo "\n";
$k=$k+1;
}
echo "\n";
}
// Use this logic to take care of remainder files
if ($remainder !== 0){
if ($remainder == 2) {
echo "\n";
for ($j=1; $j<=2; $j++) {
echo "\n";
$k=$k+1;
}
echo "\n";
echo "\n";
} elseif ($remainder == 1) {
echo "\n";
echo "\n";
$k=$k+1;
for ($j=1; $j<=2; $j++) {
echo "\n";
}
echo "\n\n";
} else warn("Remainder value doesn't make sense.\n");
}
echo "\n
\n\n";
* *