note 108460 deleted from function.rmdir by danbrown

From: Date: Thu, 10 May 2012 16:57:31 +0000
Subject: note 108460 deleted from function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187619@lists.php.net to get a copy of this message
Note Submitter: egi at gmx dot ch ---- The previous post doesn't match dot files and follows symlinks - which is probably not what you really want! This version should do the trick in all cases: <?php function rrmdir($dir) { $fp = opendir($dir); if ( $fp ) { while ( $f = readdir($fp) ) { $file = $dir . "/" . $f; if ( $f == "." || $f == ".." ) { continue; } else if ( is_dir($file) ) { rrmdir($file); } else { unlink($file); } } closedir($fp); rmdir($dir); } } ?> PS: Sorry, I blundered on the previous post (which actually should be deleted) - please ignore it :-)

« previous php.notes (#187619) next »