列出目录中的所有文件,更多信息即将到来 [英] List all files in a directory ,extra information is coming
本文介绍了列出目录中的所有文件,更多信息即将到来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码-
if ($handle = opendir('banner/')) {
while (false !== ($file = readdir($handle))) {
echo "$file";
}
closedir($handle);
}
当我运行此代码时,不必要的点(.)就要来了.
输出image-3.jpgimage-4.jpgimage-1.jpgimage-2.jpgimage-5.jpg...
为什么最后有3个点?
wher I run this code unnecessary dots(.) are coming.
output image-3.jpgimage-4.jpgimage-1.jpgimage-2.jpgimage-5.jpg...
why 3 dots are coming at the last??
推荐答案
因为.
是当前目录,而..
是父目录.
Because .
is the current directory and ..
is the parent directory.
它们始终存在.
如果您需要排除它们-只需添加
If you need to exclude them - just add
if ($file != '.' && $file != '..')
在echo
这篇关于列出目录中的所有文件,更多信息即将到来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文