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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.