Jump to content

Archived

This topic is now archived and is closed to further replies.

Woodburn2006

delete directories

Recommended Posts

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

Share this post


Link to post
Share on other sites
found this:
[code]// returns true if folder is empty or not existing
// false if folde is full

function 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_dir

Liam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.