jeeva Posted December 28, 2006 Share Posted December 28, 2006 hi frnds,i hope u can help me...will u plz tell me how can i make a directory as empty(0 files) using php?Actually i doesn't know wts in the directory. but it has to be contain nothing while clicking somthing...if any one had solve this already, plz let me know wt i have to do?Rgrds & thanksjeeva Link to comment https://forums.phpfreaks.com/topic/32028-make-a-directory-as-empty0-files/ Share on other sites More sharing options...
fert Posted December 28, 2006 Share Posted December 28, 2006 [code]$files=glob("dir name");$num=count($files);for($count=0;$count<$num;$count++){unlink($files[$count]);}[/code]that will delete all files in a directory Link to comment https://forums.phpfreaks.com/topic/32028-make-a-directory-as-empty0-files/#findComment-148656 Share on other sites More sharing options...
Stopofeger Posted December 28, 2006 Share Posted December 28, 2006 Well, u can delete the directory and recreate it. This will make the dir empty. This is the shortcut solution but not suggested. Alternatively you can loop through all the files and delete them one by one. Like given by fert. Link to comment https://forums.phpfreaks.com/topic/32028-make-a-directory-as-empty0-files/#findComment-148657 Share on other sites More sharing options...
jeeva Posted December 28, 2006 Author Share Posted December 28, 2006 Thanks a lot,it saved meRgrds jeeva Link to comment https://forums.phpfreaks.com/topic/32028-make-a-directory-as-empty0-files/#findComment-148659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.