You want to empty a directory completely of it's contents.
But you want to retain the directory itself.
$success = File::cleanDirectory($directory);
The method will return
false if the directory doesn't exist. Otherwise it returns
true when complete.
This is a wrapper on
It operates just as
File::deleteDirectory() does but it always retains the directory instead of deleting it.
See Recursively Deleting a Directory for more details.