3 回答

TA贡献1829条经验 获得超4个赞
检查一下:readdir()
此代码段应列出某个目录中的所有条目:
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry\n";
}
}
closedir($handle);
}
编辑:miah的解决方案比我的解决方案优雅得多,您应该改用他的解决方案。

TA贡献1835条经验 获得超7个赞
您正在寻找命令scandir。
$path = '/tmp';
$files = scandir($path);
以下代码将从以下位置删除.并..从返回的数组中删除scandir:
$files = array_diff(scandir($path), array('.', '..'));

TA贡献1859条经验 获得超6个赞
这也很完美$files = scandir($imgspath); $total = count($files); $images = array(); for($x = 0; $x <= $total; $x++): if ($files[$x] != '.' && $files[$x] != '..') { $images[] = $files[$x]; } endfor;
- 3 回答
- 0 关注
- 266 浏览
添加回答
举报