ฟังก์ชั่นลบโฟลเดอร์ (Remove Folder)

Function

<?php
function removeFolder($dir){
   if(!is_dir($dir))
   return false;
   for($s = DIRECTORY_SEPARATOR, $stack = array($dir), $emptyDirs = array($dir); $dir = array_pop($stack);){
   if(!($handle = @dir($dir)))
   continue;
   while(false !== $item = $handle->read())
     $item != '.' && $item != '..' && (is_dir($path = $handle->path . $s . $item) ?
     array_push($stack, $path) && array_push($emptyDirs, $path) : unlink($path));
     $handle->close();
  }
  for($i = count($emptyDirs); $i--; rmdir($emptyDirs[$i]));
}
?>

Eaxmple

removeFolder("ชื่อโฟลเดอร์");
You can leave a response, or trackback from your own site. Responses are currently closed, but you can trackback from your own site. You can skip to the end and leave a response. Pinging is currently not allowed. Both comments and pings are currently closed.
Powered by WordPress | Shop Free T-Mobile Phones Online | Thanks to Verizon Phones without Contract, MMORPG Games and Sell Car