Empty the specified directory of all files and folders.
public static cleanDirectory ( string $directory ) : boolean | ||
$directory | string | |
return | boolean |
$dir = 'path/to/directory'; cleanDirectory($dir);
$dir = 'path/to/directory'; $excludedFiles = ['.gitkeep']; cleanDirectory($dir, $excludedFiles);This example deletes all files and directories within the specified directory, except for the file '.gitkeep'. This function is not part of the core PHP functions, so it must be implemented using a package library. One such library is the Symfony Filesystem Component.
public static cleanDirectory ( string $directory ) : boolean | ||
$directory | string | |
return | boolean |