Skip to content

Instantly share code, notes, and snippets.

@welblaud
Last active February 17, 2023 16:01
Show Gist options
  • Save welblaud/1494e432971afb006caa6e73d32ea970 to your computer and use it in GitHub Desktop.
Save welblaud/1494e432971afb006caa6e73d32ea970 to your computer and use it in GitHub Desktop.
Function for removing dirs and files recursivelly in PHP
<?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