【发布时间】:2019-09-24 17:10:44
【问题描述】:
我有这个运行良好的脚本,但我需要添加一个用于搜索所有子文件夹的命令。
示例:我有一个文件夹数据,其中包含更多其他文件夹...我需要搜索此文件夹上的文件。
$dir = 'data';
$exclude = array('.', '..', '.htaccess');
$q = (isset($_GET['q'])) ? strtolower($_GET['q']) : '';
$res = opendir($dir);
while(false !== ($file = readdir($res))) {
if(strpos(strtolower($file), $q) !== false &&!in_array($file, $exclude)) {
echo "<a href='$dir/$file'>$file</a>";
echo "<br>";
}
}
closedir($res);
【问题讨论】:
标签: php