The rmdir() function removes an empty directory. With that, the file must have the relevant permissions required to delete the directory.
Syntax
rmdir(dir, context)
Parameters
rmdir − The directory to be removed.
context − Specify the behavior of the stream.
Return
The rmdir() function returns True on success or False on failure.
Example
<?php $file_path = "amit"; if(!rmdir($file_path)) { echo ("Could not remove $path"); } ?>
Output
TRUE
Let us see another example.
Example
<?php mkdir(‘documents); $dir= "documents"; // using rmdir() to remove directory rmdir($dir); ?>
Output
TRUE