Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. delete_files('/path/for/the/directory/');
  2.  
  3. /*
  4.  * php delete function that deals with directories non-recursively
  5.  */
  6. function delete_files($target) {
  7.         $files = glob( $target . '*', GLOB_MARK );
  8.         foreach( $files as $file )
  9.         {
  10.             if(is_dir($file)){
  11.                 rmdir( $file );
  12.             } elseif(is_file($file)) {
  13.                 unlink( $file );  
  14.             }    
  15.         }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement