<?php
/* settings */
$image_dir = 'gallery/';
$per_column = 3;
$count=0;
if ($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(strstr($file,'-thumb'))
{
$files[] = $file;
}
}
}
closedir($handle);
}
if(count($files))
{
foreach($files as $file)
{
$count++;
echo '<a class="thumbnail" rel="one-big-group" href="',$image_dir,str_replace('-thumb','',$file),'"><img src="',$image_dir,$file,'" width="100" height="100" /></a>';
if($count % $per_column == 0) { echo '<div class="clear"></div>'; }
}
}
else
{
echo '<p>There are no images in this gallery.</p>';
}
?>
如何爲每個圖像添加標題? 非常感謝您的回答!如何將標題添加到此自動創建的php庫?
什麼樣的標題?像你從哪裏得到每張照片的標題? – Vap0r
這就是我想知道如何去做的。爲每個文件寫一個標題,並在當前腳本中使用php顯示它。這可能與數組有關嗎? –