$fileInfo) { if ($iterator->isDot()) { continue; } if ($fileInfo->isDir()) { rmdir($filename); } else { unlink($filename); } } rmdir($dir); } }