Created
October 1, 2014 10:38
-
-
Save ZiTAL/09892362a7379513cd92 to your computer and use it in GitHub Desktop.
php delete folders recursively
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
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