note 89497 deleted from function.rmdir by danbrown

From: Date: Mon, 06 Apr 2009 16:13:11 +0000
Subject: note 89497 deleted from function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152868@lists.php.net to get a copy of this message
Note Submitter: david at liip.ch ---- Thanks for that compact recursive delete function. Note that it does not delete the directory initially passed to it. rmdir it afterwards or modify the function like this: <?php function rmdir_recurse($path) { $path= rtrim($path, '/').'/'; $handle = opendir($path); for (;false !== ($file = readdir($handle));) if($file != "." and $file != ".." ) { $fullpath= $path.$file; if( is_dir($fullpath) ) { rmdir_recurse($fullpath); } else { unlink($fullpath); } } closedir($handle); rmdir($path); } ?> [NOTE BY danbrown AT php DOT net: This function was originally written by (elprez AT free DOT fr) on 02-DEC-2008 with the following note: "A simple recursive function freely inspired from hoffmeister."]

« previous php.notes (#152868) next »