Luno1599
23-11-2009, 04:49 PM
Hey,
I have just designed this script, there is a folder with 10 images in it...
01.jpg
01t.jpg
02.jpg
02t.jpg ect... all the way to 05.jpg
I want it to display 4 images per div, so it should echo 4 images in 1 div then 1 image in another div because I DONT want the script to display the images with t in it so it will NOT display 01t.jpg ect...
Can you help me fix my code so it doesnt take into account the images with a t in the name.
<?php
$image_dir = "";
/* settings */
$per_column = 4;
/* step one: read directory, make array of files */
if ($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
/* step two: loop through, format gallery */
if(count($files)){
echo "<div>";
foreach($files as $file){
$count++;
echo '
<span><img width="44" height="44" src="'$image_dir''$file'" alt="#" /></span>
';
if($count % $per_column == 0) { echo '</div>'; }
}}
else
{
echo ''; // Error no images
}
echo "";
}
?>
Dan =)
I have just designed this script, there is a folder with 10 images in it...
01.jpg
01t.jpg
02.jpg
02t.jpg ect... all the way to 05.jpg
I want it to display 4 images per div, so it should echo 4 images in 1 div then 1 image in another div because I DONT want the script to display the images with t in it so it will NOT display 01t.jpg ect...
Can you help me fix my code so it doesnt take into account the images with a t in the name.
<?php
$image_dir = "";
/* settings */
$per_column = 4;
/* step one: read directory, make array of files */
if ($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
/* step two: loop through, format gallery */
if(count($files)){
echo "<div>";
foreach($files as $file){
$count++;
echo '
<span><img width="44" height="44" src="'$image_dir''$file'" alt="#" /></span>
';
if($count % $per_column == 0) { echo '</div>'; }
}}
else
{
echo ''; // Error no images
}
echo "";
}
?>
Dan =)