How To Remove an Empty Directory


How To Remove an Empty Directory? - PHP Script Tips - Working with Directoris and Files



If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir():

if (file_exists("/temp/download")) {
  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.

2007-04-23, 4702👍, 0💬