Last active
December 22, 2015 01:38
-
-
Save guelau/6397285 to your computer and use it in GitHub Desktop.
Recursive rmdir
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 | |
function rmdir_r ($d) | |
{ | |
if (is_dir ($d)) { | |
$list = scandir ($d); | |
foreach ($list as $object) { | |
if ($element != '.' && $element != '..') { | |
if (is_dir ($d . '/' . $element)) { | |
rmdir_r ($d . '/' . $element); | |
} else { | |
unlink ($d . '/' . $element); | |
} | |
} | |
} | |
rmdir ($d); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment