2
即时通讯使用php很新,我发现了一个库脚本,从文件夹中获取所有照片并显示它们。我试图让这个数组忽略名为'app_thumbnails'的'照片'文件夹中的所有文件夹。在php数组中忽略文件名
的代码创建数组:
//READ FILES AND FOLDERS
$files = array();
$dirs = array();
if ($handle = opendir($currentdir))
{
while (false !== ($file = readdir($handle)))
{
// Change filename to display date
$displaydate= date('jS M Y', strtotime($file));
// Load folders into array
if (is_directory($currentdir . "/" . $file))
{
if ($file != "." && $file != "..")
{
// Set thumbnail to folder.jpg if found:
if (file_exists(GALLERY_ROOT . "photos/" . $file . "/folder.jpg"))
{
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . urlencode(ltrim($_GET['dir'] . "/" . $file, "/")) . "'><em> " . $displaydate . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=photos/" . $file . "/folder.jpg&size=$thumb_size' alt='$label_loading' /></a></li>");
} else
{
//Set thumbnail to first image found (if any):
unset ($firstimage);
$firstimage = getfirstImage("$currentdir/" . $file);
if ($firstimage != "") {
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . urlencode(ltrim($_GET['dir'] . "/" . $file, "/")) . "'><em> " . $displaydate . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=$thumbdir/" . $file . "/" . $firstimage . "&size=$thumb_size' alt='$label_loading' /></a></li>");
} else {
//If no folder.jpg or image is found, then display default icon:
$dirs[] = array(
"name" => $file,
"date" => filemtime($currentdir . "/" . $file),
"html" => "<li><a href='?dir=" . urlencode(ltrim($_GET['dir'] . "/" . $file, "/")) . "'><em> " . $displaydate . "</em><span></span><img src='" . GALLERY_ROOT . "images/folder_" . strtolower($folder_color) . ".png' width='$thumb_size' height='$thumb_size' alt='$label_loading' /></a></li>");
}
}
}
}
,你可以在这里看到我的画廊例如:http://design-wright.co.uk/bunker/gallery/gallery.php
感谢您的时间家伙。 alsweet
非常感谢,很棒! – alsweet 2010-11-16 16:05:30
很高兴帮助:) – acm 2010-11-16 16:07:23