Hello,
I want to delete a directory, the example code below deletes the contents of the directory but does not delete the “bulut” directory. How can I delete the “bulut” directory?
$dir = 'bulut';
delete_directory($dir);
function delete_directory($dirPath){
$dir = $dirPath;
if(is_dir($dir)){
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST
);
foreach($files as $file){
if ($file->isDir()){
rmdir($file->getRealPath());
}else{
unlink($file->getRealPath());
}
}
rmdir($dir);
}
}