I am new to php and am trying to create an image gallery with captions being pulled for a text file. The images are in a directory. The images load fine but the captions only show the first letter of each under the image???
Here’ my code:
<?php
$images = "./images/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of above)
$cols = 2; # Number of columns to display
$text = "image_gallery_descriptions.txt";
$fh=fopen($text, "r");
while(!feof($fh))
{
$temp = explode(",", $line);
$description[$temp[0]] = $temp[1];
$line=fgets($fh);
unset($temp);
}
if ($handle = opendir($images)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
$files[] = $file;
}
}
closedir($handle);
}
$colCtr = 0;
echo '
';
foreach($files as $file)
{
if($colCtr %$cols == 0)
echo '
|
';
$allfiles .= $file . ',
';
echo '
' . $description[$file][0] . ' | ';
$colCtr++;
}
echo '
' . "rn";
?>
Your help is appreicated.