gpt4 book ai didi

php - 忽略 php 数组中的文件名

转载 作者:行者123 更新时间:2023-12-02 06:43:39 26 4
gpt4 key购买 nike

我是 PHP 的新手,我发现了一个图库脚本,它可以从一个文件夹中获取所有照片并显示它们。我试图让数组忽略这个名为“app_thumbnails”的“照片”文件夹中的所有文件夹。

创建数组的代码是:

//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>&nbsp;&nbsp;&nbsp;&nbsp;" . $displaydate . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=photos/" . $file . "/folder.jpg&amp;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>&nbsp;&nbsp;&nbsp;&nbsp;" . $displaydate . "</em><span></span><img src='" . GALLERY_ROOT . "createthumb.php?filename=$thumbdir/" . $file . "/" . $firstimage . "&amp;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>&nbsp;&nbsp;&nbsp;&nbsp;" . $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

谢谢你们抽出时间来。永远甜蜜

最佳答案

替换

if ($file != "." && $file != ".." )

if ($file != "." && $file != ".." && $file != "app_thumbnails")

关于php - 忽略 php 数组中的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4195975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com