Remove empty subfolders with PHP

后端 未结 6 1273
小鲜肉
小鲜肉 2020-12-09 22:38

I am working on a PHP function that will recursively remove all sub-folders that contain no files starting from a given absolute path.

Here is the code developed so

6条回答
  •  时光说笑
    2020-12-09 22:44

    You can execute a unix command to remove empty directories.

    exec("find $starting_from_path -type d -empty -exec rmdir {} \; 2>/dev/null");

提交回复
热议问题