本文介绍了列出目录中的所有文件,更多信息即将到来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码-
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
更多推荐
列出目录中的所有文件,更多信息即将到来
发布评论