note 58987 deleted from function.rmdir by mazzanet

From: Date: Wed, 23 Nov 2005 09:30:27 +0000
Subject: note 58987 deleted from function.rmdir by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-98964@lists.php.net to get a copy of this message
Note Submitter: matt at mrswebsolutions dot com ---- Nice little function to recursivly remove a directory and all its sub directories and files. Tested until about level 5. function rmdirr($dir) { if (is_dir($dir)) { if ($dc = opendir($dir)) { while (($node = readdir($dc)) !== false) { if ($node != "." && $node != "..") { $slash = (PHP_OS == 'WIN32') ? "\\" : "/"; is_dir($dir . $slash .$node)? rmdirr($dir . $slash .$node) : unlink($dir . $slash .$node); } } closedir($dc); } rmdir($dir); } }

« previous php.notes (#98964) next »