This article mainly introduces PHP7 based on recursive implementation of the method of deleting empty folders, combined with specific examples to analyze the PHP7 recursive traversal directory and judgment, delete and other related operations skills, the need for friends can refer to the next
<?php$path = ' d:/'; rmdir_1 ($path); function rmdir_1 ($path) { $files = Scandir ($path);//delete current directory and previous level directory 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); }? >
Related recommendations:
PHP7 example code for removing an empty folder based on a recursive implementation
Python methods for deleting empty files and empty folders
PHP7 What should I do if I delete an empty folder?