Showing posts with label delete all content in directory. Show all posts
Showing posts with label delete all content in directory. Show all posts

Thursday, July 3, 2014

deleting all files from a folder using php?

 function recursiveDelete($str){
        if(is_file($str)){
            return @unlink($str);
        }
        elseif(is_dir($str)){
            $scan = glob(rtrim($str,'/').'/*');
            foreach($scan as $index=>$path){
                $this->recursiveDelete($path);
            }
            return @rmdir($str);
        }
    }