Woodburn2006 Posted September 2, 2006 Share Posted September 2, 2006 is it possible to delete directories using php? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 2, 2006 Share Posted September 2, 2006 unlink($folder); or rmdir($folder);should do the trick :)RegardsLiam Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 2, 2006 Author Share Posted September 2, 2006 thanks, is there anyway of checking to see if the folder has contents? because if there are no contents i want to delete it but if there are then i want to leave it Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 2, 2006 Share Posted September 2, 2006 found this:[code]// returns true if folder is empty or not existing// false if folde is fullfunction is_empty_folder($dir) {if (is_dir($dir)) { $dl=opendir($dir); if ($dl) { while($name = readdir($dl)) { if (!is_dir("$dir/$name")) { //<--- corrected here return false; break; } } closedir($dl); } return true; } else return true;} [/code]on http://uk2.php.net/is_dirLiam Quote Link to comment 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.