note 75473 added to function.rmdir

From: Date: Thu, 31 May 2007 22:14:24 +0000
Subject: note 75473 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-127090@lists.php.net to get a copy of this message
equivalent of : rmdir -rf ie. remove a directory and everything that's in it. Note that after calling this function the current working directory of the script will be the parent of the directory you deleted. <?php function rmdir_rf($dirname) { if ($dirHandle = opendir($dirname)) { chdir($dirname); while ($file = readdir($dirHandle)) { if ($file == '.' || $file == '..') continue; if (is_dir($file)) rmdir_rf($file); else unlink($file); } chdir('..'); rmdir($dirname); closedir($dirHandle); } } ?> ---- Server IP: 66.207.199.35 Probable Submitter: 66.131.22.158 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/75473 Del: integrated -- https://master.php.net/note/delete/75473/integrated Del: useless -- https://master.php.net/note/delete/75473/useless Del: bad code -- https://master.php.net/note/delete/75473/bad+code Del: spam -- https://master.php.net/note/delete/75473/spam Del: non-english -- https://master.php.net/note/delete/75473/non-english Del: in docs -- https://master.php.net/note/delete/75473/in+docs Del: other reasons-- https://master.php.net/note/delete/75473 Reject -- https://master.php.net/note/reject/75473 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127090) next »