note 98777 deleted from function.rmdir by danbrown

From: Date: Wed, 07 Jul 2010 13:54:15 +0000
Subject: note 98777 deleted from function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170756@lists.php.net to get a copy of this message
Note Submitter: afshin dot meh at gmail dot com ---- You can empty a directory with 2 ways, for example if you want to empty "phpdir" you can do: <?php if(is_dir("phpdir")){ rmdir("phpdir"); mkdir("phpdir"); } ?> Or you can use this: <?php $dir = opendir("phpdir"); // get each entry while($entryName = readdir($dir)) { if(trim($entryName)=="." or trim($entryName)==".."){ continue; } unlink($entryName); } ?> Both codes empty an directory but i think first code is faster.

« previous php.notes (#170756) next »