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
https://forums.phpfreaks.com/topic/244509-method-feedback/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.