dreamwest Posted May 18, 2009 Share Posted May 18, 2009 How can i delete an entire directories contents but keep the directory itself 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(); ?> Link to comment https://forums.phpfreaks.com/topic/158573-delete-files/#findComment-836353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.