Last active
February 17, 2023 16:01
-
-
Save welblaud/1494e432971afb006caa6e73d32ea970 to your computer and use it in GitHub Desktop.
Function for removing dirs and files recursivelly in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rrmdir(string $dirPath): bool { | |
array_map(static fn (string $filePath) => is_dir($filePath) ? rrmdir($filePath) : unlink($filePath), glob($dirPath . '/' . '*')); | |
return rmdir($dirPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment