php - deleting all files from a folder, excluding some files from being deleted -


The following thread (first post) I have successfully completed the deletion of all files from the folder using php.

This is the code I use:

  $ files = glob ('path / to / temp / *'); // get all file name foreach ($ files as $ files) {// iterative files if (is_file ($ file)) unlink ($ file); // delete file}  

I want to exclude some files from being deleted. What code adjustment should I apply?

  $ files = glob ('path / per / temporary / *'); // Receive all filename $ exemption = [["amazingfile_a", "amazingfile_b"]; Foreign Currency (files as $ $ file) {// ifre file (if_file ($ file) and amp; amp;; in_array (end (explosion ("/", $ file)), $ exceptions ($ File); // delete file}  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -