note 25639 added to function.rmdir

From: Date: Tue, 01 Oct 2002 09:42:19 +0000
Subject: note 25639 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-37459@lists.php.net to get a copy of this message
recusive function to empty a directory function delete_all_from_dir($Dir){ // delete everything in the directory if ($handle = @opendir($Dir)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") { continue; } if (is_dir($Dir.$file)){ // call self for this directory delete_all_from_dir($Dir.$file."/"); chmod($Dir.$file,0777); rmdir($Dir.$file); //remove this directory }else { chmod($Dir.$file,0777); unlink($Dir.$file); // remove this file } } } @closedir($handle); } -- http://www.php.net/manual/en/function.rmdir.php http://master.php.net/manage/user-notes.php?action=edit+25639 http://master.php.net/manage/user-notes.php?action=delete+25639 http://master.php.net/manage/user-notes.php?action=reject+25639

« previous php.notes (#37459) next »