Filter required files in php
1.
[Code][PHP] code
$ Value) {create_dir ($ root, $ value, $ target_time, $ target_dir) ;}} else {$ modify_time = filemtime ($ filename ); // add a file using filectime $ create_time = filectime ($ filename); if ($ modify_time >=$ target_time | $ create_time >=$ target_time) {$ root = preg_quote ($ root); $ str = file_get_contents ($ filename); $ filename = preg_replace ("@ $ root @", "", $ filename ); if (! Is_file ($ target_dir. $ filename) {file_put_contents ($ target_dir. $ filename, $ str);} echo $ filename ."
";}} Else {echo 'parameter error'; return false ;}// the second parameter controls whether to delete all or just delete the empty directory function remove_dir ($ target_dir, $ all_flg = false) {foreach (glob ("$ target_dir/*") as $ key => $ value) {if (is_dir ($ value) & count (glob ("$ value/*") = 0) {// delete the directory rmdir ($ value) for which the first-level directory is empty );} else if (is_dir ($ value) & count (glob ("$ value/*")> 0) {// verify all the subdirectories of the current directory. foreach (glob ("$ value/*") as $ sub_key => $ sub_value) {remove_dir ($ sub_value, $ all_flg );} // after processing in the previous step, return to the current directory and check whether the subdirectories of the current directory are empty. remove_dir ($ value, $ all_flg ); // if the current directory is empty after processing, delete if (is_dir ($ value) & count (glob ("$ value /*")) = 0) {rmdir ($ value) ;}} if ($ all_flg) {if (is_file ($ value) {unlink ($ value );}}}} // first clear the target directory remove_dir ($ target_dir, true); // re-create the directory create_dir ($ dir, $ dir, $ target_time, $ target_dir); sleep (1 ); // filter the remove_dir Directory ($ target_dir );