PHP deletes the code for a multilayer directory
PHP Delete multi-level directory
Read ()) {if (Is_file ($pathdir. ') /'. $a) && ($a! = '. ') && ($a! = ' ... ')) {unlink ($pathdir. ') /'. $a);} If it is a file, delete the IF (Is_dir ($pathdir) directly. /'. $a) && ($a! = '. ') && ($a! = ' ... ')) {//If it is a directory if (!is_empty_dir ($pathdir. ') /'. $a))//Is empty {//if not, call itself, but the original path + his subordinate directory name deltree ($pathdir. ' /'. $a);} if (Is_empty_dir ($pathdir. ' /'. $a)) {//If it is empty, delete rmdir ($pathdir. ' /'. $a);}} $d->close (); echo "must first delete all files under the directory";//debug}}function Is_empty_dir ($pathdir) {//Determine if the directory is empty $d=opendir ($pathdir); $i = 0; while ($a =readdir ($d)) {$i + +;} Closedir ($d); if ($i >2) {return false;} else return true;}? >