Remove an empty directory in php
An empty existing directory can be removed by using the rmdir() php function.
Example use of rmdir():
<?php if (file_exists("/temp/test")) { rmdir("/temp/test"); print("Directory removed.\n"); } else { print("Directory does not exist.\n"); } ?>
This script will print:
Directory removed.
If you run this script again, it will print:
Directory does not exist.
Filed Under: PHP File Handling