note 91797 deleted from function.rmdir by danbrown

From: Date: Wed, 15 Sep 2010 21:24:43 +0000
Subject: note 91797 deleted from function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172612@lists.php.net to get a copy of this message
Note Submitter: senthryl at NOSPAM dot geemail dot com ---- Here's another version of the recursive directory removal. This version requires PHP 5, and returns TRUE on success or FALSE on failure. <?php function deleteDirectory($dir) { if (!file_exists($dir)) return true; if (!is_dir($dir)) return unlink($dir); foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') continue; if (!deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) return false; } return rmdir($dir); } ?>

« previous php.notes (#172612) next »