这篇文章主要介绍了php判断并删除空目录及空子目录的方法,可实现遍历目标文件夹判断是否为空及删除空目录的功能,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php判断并删除空目录及空子目录的方法。分享给大家供大家参考。具体实现方法如下:
步骤如下:
1.遍历目录及子目录
2.使用 scandir 判断目录是否为空,为空则使用rmdir 删除。
使用 shell 则简单很多:
find 目标文件夹 -mindepth 1 -depth -empty -type d -exec rm -r {} \;
希望本文所述对大家的php程序设计有所帮助。
,
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
