Clean Folder in PHP
$debug='false';
$folder='book/pages/';
if ($debug) {
// echo "Cleaning folder $folder ...
";
}
$d = dir($folder);
while (false !== ($entry = $d->read())) {
$isdir = is_dir($folder."/".$entry);
if (!$isdir and $entry!="." and $entry!="..") {
unlink($folder."/".$entry);
} elseif ($isdir and $entry!="." and $entry!="..") {
empty_folder($folder."/".$entry,$debug);
rmdir($folder."/".$entry);
}
}
$d->close();