This should work, but I have not tested it, just call deleteDir with the directory you want to remove.
<?
function deleteDir($dir) {
if(is_dir($dir)) {
$dir_handle = opendir($dir);
while($entry = readdir($dir)) {
if ($entry!= "." && $entry!= "..") {
unlink($entry);
}
}
}
closedir($dir);
rmdir($dir);
}
?>