PHP recursive delete function

后端 未结 3 1686
误落风尘
误落风尘 2021-01-19 03:13

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

3条回答
  •  遇见更好的自我
    2021-01-19 03:34

    1. You could provide an extra array parameter $exclusions to recursive_remove_directory(), but you'll have to pass this parameter every time recursively.

    2. Make $exclusions global. This way it can be accessed in every level of recursion.

提交回复
热议问题