Woodburn2006 Posted September 2, 2006 Share Posted September 2, 2006 is it possible to delete directories using php? Link to comment https://forums.phpfreaks.com/topic/19462-delete-directories/ 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 Link to comment https://forums.phpfreaks.com/topic/19462-delete-directories/#findComment-84521 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 Link to comment https://forums.phpfreaks.com/topic/19462-delete-directories/#findComment-84524 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 Link to comment https://forums.phpfreaks.com/topic/19462-delete-directories/#findComment-84528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.