PHP recursive directory remove function

PHP recursive directory remove function

Popular content

Donate to Us


Donate by clicking Ads :)

Who's online

There are currently 0 users and 18 guests online.

PHP recursive directory remove function

<?phpfunction RemoveDir($sDir) {if (is_dir($sDir)) {$sDir = rtrim($sDir, '/');$oDir = dir($sDir);while (($sFile = $oDir->read()) !== false) {if ($sFile != '.' && $sFile != '..') {(!is_link("$sDir/$sFile") && is_dir("$sDir/$sFile")) ? RemoveDir("$sDir/$sFile") : unlink("$sDir/$sFile");}}$oDir->close();rmdir($sDir);return true;}return false; }?>Heshan Wanigasooriya

Share/Save
10
Average: 10 (1 vote)
Your rating: None
Tags
Comments

Post new comment

 
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.