Search
| PHP code for recursive deletion |
|
|
|
| Programming - PHP |
| Wednesday, 01 July 2009 20:04 |
|
![]()
/* This code will delete all the contents of a directory including sub directories*/
$path="/image/icon/"; //give the complete path here deletedir($path); function deletedir($dir) { $iterator = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { if ($file->isDir()) {rmdir($file->getPathname()); } else { unlink($file->getPathname()); } } rmdir($dir); } ?> |
| Last Updated on Thursday, 02 July 2009 06:35 |





