function deleteDirectory($dir) { if (!file_exists($dir)) { return true; } if (!is_dir($dir)) { return unlink($dir); } foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') { continue; } if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { return false; } } return rmdir($dir); }In this example, the `deleteDirectory` function is defined and takes a single parameter, which is the name of the directory to be deleted. This function recursively iterates over the contents of the directory and deletes each file and subdirectory. This function is part of the PHP core and does not require any additional packages or libraries.