PHP:检查目录是否为空,最好最简单的方法是什么? [英] PHP: What is the best and easiest way to check if directory is empty or not
本文介绍了PHP:检查目录是否为空,最好最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
使用 glob
:
if(count(glob(path / *))=== 0 ){// empty
关于 glob
是它不返回。
和 ..
目录。
I got a root directory with 100s of dynamically generated folders. As time goes some of these folders will need to be extirpated from system on the condition that this(ese) directories(s) must be empty. What would be the best shortest, easiest and/or most effective way to achieve that?
解决方案
Use glob
:
if (count(glob("path/*")) === 0 ) { // empty
A nice thing about glob
is that it doesn't return .
and ..
directories.
这篇关于PHP:检查目录是否为空,最好最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文