dreamwest Posted May 18, 2009 Share Posted May 18, 2009 How can i delete an entire directories contents but keep the directory itself Quote Link to comment https://forums.phpfreaks.com/topic/158573-delete-files/ Share on other sites More sharing options...
JonnoTheDev Posted May 18, 2009 Share Posted May 18, 2009 <?php $d = dir("/path/to/dir/"); while($contents = $d->read()) { if($contents != "." && $contents != "..") { unlink($contents); } } $d->close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158573-delete-files/#findComment-836353 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.