note 91562 deleted from function.rmdir by danbrown

From: Date: Wed, 15 Sep 2010 21:24:48 +0000
Subject: note 91562 deleted from function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172613@lists.php.net to get a copy of this message
Note Submitter: j_terlouw at planet dot nl ---- This function deletes a folder and all it's subfolders and files. <?php function remove_dir($current_dir) { if($dir = @opendir($current_dir)) { while (($f = readdir($dir)) !== false) { if($f > '0' and filetype($current_dir.$f) == "file") { unlink($current_dir.$f); } elseif($f > '0' and filetype($current_dir.$f) == "dir") { remove_dir($current_dir.$f."\\"); } } closedir($dir); rmdir($current_dir); } } ?> Might need some improvement, but it works fine.

« previous php.notes (#172613) next »