Skip to content

Instantly share code, notes, and snippets.

@ZiTAL ZiTAL/rmdirr
Created Oct 1, 2014

Embed
What would you like to do?
php delete folders recursively
function rmdirr($folder)
{
$aDeny = array('.', '..');
$resources = scandir($folder);
foreach($resources as $r)
{
if(!in_array($r, $aDeny))
{
$tmp = $folder."/".$r;
if(is_dir($tmp))
rmdirr($tmp);
else
unlink($tmp);
}
}
rmdir($folder);
}
rmdirr('/tmp/example');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.