Skip to content

Instantly share code, notes, and snippets.

@guelau
Last active December 22, 2015 01:38
Show Gist options
  • Save guelau/6397285 to your computer and use it in GitHub Desktop.
Save guelau/6397285 to your computer and use it in GitHub Desktop.
Recursive rmdir
<?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