deleting or removing directories or folders with php is simple

rmdir()


Removes directory

example, lets say i want to remove or delete a directory called images, this is how i would do it with php


$mydir = '/path/directory/images/';

rmdir($mydir);


thats it

but this would be a more practical use, first i want to check if the directory even exists:

$mydir = '/path/directory/images/';
if (is_dir($mydir)) {
rmdir($mydir);
} else {
echo $mydir.' does not exists';
}