The Little Guy Posted August 11, 2011 Share Posted August 11, 2011 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 More sharing options...
Maq Posted August 11, 2011 Share Posted August 11, 2011 Why don't you just use "rm -r" in the shell_exec? Link to comment https://forums.phpfreaks.com/topic/244509-method-feedback/#findComment-1255917 Share on other sites More sharing options...
The Little Guy Posted August 11, 2011 Author Share Posted August 11, 2011 Why don't you just use "rm -r" in the shell_exec? good call! I like that better Link to comment https://forums.phpfreaks.com/topic/244509-method-feedback/#findComment-1255929 Share on other sites More sharing options...
Maq Posted August 11, 2011 Share Posted August 11, 2011 Why don't you just use "rm -r" in the shell_exec? good call! I like that better You might run into a permission errors, I haven't really used shell_exec much so I can't really give any advice. Link to comment https://forums.phpfreaks.com/topic/244509-method-feedback/#findComment-1255937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.