ahmed19981973

Untitled

Mar 9th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1.  
  2. function delete_dir_safety($file_path){
  3.     $files=scandir($file_path);
  4.     foreach ( $files as $item) {
  5.         if ($item==='.'||$item==='..')
  6.             continue;
  7.         if (is_dir($file_path))
  8.             delete_dir_safety($file_path.DIRECTORY_SEPARATOR.$item);
  9.         else
  10.             unlink($file_path.DIRECTORY_SEPARATOR . $item);
  11.     }
  12.     rmdir($file_path);
  13.     if (!is_dir($file_path))
  14.         return true ;
  15.     else
  16.         return false ;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment