Jump to content

method feedback


The Little Guy

Recommended Posts

I have this method, I haven't tested it yet, but before I attempt to, do you have any thoughts on it?

 

It is supposed to take a dir path and remove all the files and directories within that path.

 

	private function delete_directory_structure($path){
	$path = rtrim(trim($path),"/");
	$files_and_dirs = glob($path."/*");
	foreach($files_and_dirs as $fpath){
		if(is_file($fpath))
			unlink ($fpath);
		if(is_dir($fpath))
			$this->del_dirs[] = $fpath;
	}
	$key = array_search($path, $this->del_dirs);
	if($key != false){
		unset($this->del_dirs[$key]);
	}
	if(count($this->del_dirs) > 0){
		$this->delete_directory_structure($this->del_dirs[0]);
	}
	return true;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.