Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Created October 1, 2014 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZiTAL/09892362a7379513cd92 to your computer and use it in GitHub Desktop.
Save ZiTAL/09892362a7379513cd92 to your computer and use it in GitHub Desktop.
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