This article mainly introduces the method of deleting empty folders based on recursion in php7. It analyzes the recursive directory traversal and judgment, deletion and other related operation skills of php7 based on specific examples. Friends in need can refer to it
<?php $path = 'd:/'; rmDir_1($path); function rmDir_1($path) { $files = scandir($path); // 删除当前目录和上一级目录 foreach($files as $key => $file) { if ( $file == '.' || $file == '..') { unset($files[$key]); } } if ($files) { foreach($files as $file) { if (is_dir($path . '/' . $file)) { //echo 'dir=' . $path . '/' . $file . PHP_EOL; rmDir_1($path . '/' . $file); } } } else { //echo 'rmdir=' . $path . PHP_EOL; rmdir($path); } } ?>
php7 based on recursive implementationDelete empty filesFolder method example code
PythonHow to delete empty files and empty folders
php7Delete What should I do with the empty file folder?
The above is the detailed content of Detailed explanation of the method of deleting empty folders based on recursion in php7. For more information, please follow other related articles on the PHP Chinese website!