everogrin Posted June 21, 2007 Share Posted June 21, 2007 Hi all I use this code to delete a directory (called with: full_rmdir("../dir"); ) <?php function full_rmdir($dirname){ if ($dirHandle = opendir($dirname)){ $old_cwd = getcwd(); chdir($dirname); while ($file = readdir($dirHandle)){ if ($file == '.' || $file == '..') continue; if (is_dir($file)){ if (!full_rmdir($file)) echo "Error"; return false; }else{ if (!unlink($file)) echo "Error"; return false; } } closedir($dirHandle); chdir($old_cwd); if (!rmdir($dirname)) echo "Error"; return false; echo "Directory deleted"; return true; }else{ echo "Error"; return false; } } ?> With this code above, -if I delete a directory it's ok; -if I delete more directories (with a for structure) I have more messages "Directory deleted"; -if I delete some directories (some deleted and some yet to delete) I have more error messages and more good messages. Ho can I do have the right messages? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/56529-delete-a-directory/ Share on other sites More sharing options...
trq Posted June 21, 2007 Share Posted June 21, 2007 Sorry... what exactly is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/56529-delete-a-directory/#findComment-279191 Share on other sites More sharing options...
everogrin Posted June 21, 2007 Author Share Posted June 21, 2007 the problem is that I would to print 1 message of folder/s deleted OR 1 message of folder/s not deleted. The code above, print (with echo) 1 message if the folder/s is deleted (it's ok) 1 message if the folder/s is not deleted (it's ok) 1 or more messages if I delete more than one folder 1 or more messages if I delete folder/s already deleted and some yet to delete. Quote Link to comment https://forums.phpfreaks.com/topic/56529-delete-a-directory/#findComment-279198 Share on other sites More sharing options...
everogrin Posted June 21, 2007 Author Share Posted June 21, 2007 up Quote Link to comment https://forums.phpfreaks.com/topic/56529-delete-a-directory/#findComment-279445 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.