Delete Directory PHP
To delete directories in PHP, we need to use the rmdir() funciton. rmdir() takes a single argument, the name of the directory to be deleted. The deletion will only be successful if the directory is empty. If the directory contains files or other subdirectories the deletion cannot be performed until those files and subdirectories are also deleted.
<?php if ( is_dir('/tmp/bin")) rmdir("/tmp/bin"); ?>
In the above code, first we have condition like If the “bin” directory exists then delete otherwise not delete.