gpt4 book ai didi

PHP:在每次加载时扫描目录以查找文件

转载 作者:搜寻专家 更新时间:2023-10-31 21:38:22 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Caching readdir()

我设置了我的网站,这样我就有了干净的 URL,并且文件本身位于不同级别的文件夹中。为了管理它,我使用以下脚本将我的包含定向到页面的更下方。

    function listFolderFiles($dir,$exclude){
global $flist;
$ffs = scandir($dir);
foreach($ffs as $ff)
{
if(is_array($exclude) and !in_array($ff,$exclude))
{
if($ff != '.' && $ff != '..')
{
if(!is_dir($dir.'/'.$ff))
{
}
if(is_dir($dir.'/'.$ff))
{
listFolderFiles($dir.'/'.$ff,$exclude);
}
if((is_dir($dir.'/'.$ff)) != 1 && strtolower(substr($ff, strrpos($ff, '.') + 1)) == 'php')
{
$name = basename($ff, ".php");
$flist[] .= $name;
}
}
}
}
}
listFolderFiles('content/',array('filelist.php'));
$removing = array('_en','_es');
$pages = str_replace($removing, "", $flist);
unset($dir, $exclude, $flist);
listFolderFiles('content/Beginner/',array('filelist.php'));
$removing = array('_en','_es');
$beginner = str_replace($removing, "", $flist);
unset($dir, $exclude, $flist);
listFolderFiles('content/Intermediate/',array('filelist.php', $beginner));
$removingi = array('_en','_es');
$intermediate = str_replace($removingi, "", $flist);
unset($dir, $exclude, $flist);
listFolderFiles('content/Advanced/',array('filelist.php', $beginner));
$removinga = array('_en','_es');
$advanced = str_replace($removinga, "", $flist);

有没有更快的方法来执行此代码,因为它目前用于每个页面加载,我只需要在添加新文件时更新它。

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