Created
December 24, 2011 07:59
-
-
Save devpilot/1516754 to your computer and use it in GitHub Desktop.
Delete directory with content in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Delete directory with content in it | |
* @author Pilot | |
* @param string $directory Directory to delete | |
*/ | |
function del_dir($directory) { | |
$content = scandir($directory); | |
unset($content[0], $content[1]); | |
foreach ($content as $filename) { | |
if (is_dir($path = $directory . '/' . $filename)) { | |
del_dir($path); | |
} else { | |
unlink($directory . '/' . $filename); | |
} | |
} | |
rmdir($directory); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment