I wrote recursive PHP function for folder deletion. I wonder, how do I modify this function to delete all files and folders in webhosting, excluding given array of files and
You could provide an extra array parameter $exclusions to recursive_remove_directory(), but you'll have to pass this parameter every time recursively.
$exclusions
recursive_remove_directory()
Make $exclusions global. This way it can be accessed in every level of recursion.