note 75594 added to function.rmdir

From: Date: Thu, 07 Jun 2007 11:22:44 +0000
Subject: note 75594 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-127265@lists.php.net to get a copy of this message
Improvement of function from "brousky - gmail": -Removes a directory and everything in it -After calling this function the current working directory (cwd) of the script won't be changed -Function returns true/false <?php function full_rmdir($dirname) { if ($dirHandle = opendir($dirname)) { $old_cwd = getcwd(); chdir($dirname); while ($file = readdir($dirHandle)) { if ($file == '.' || $file == '..') continue; if (is_dir($file)) { if (!rmdir_rf($file)) return false; } else { if (!unlink($file)) return false; } } closedir($dirHandle); chdir($old_cwd); if (!rmdir($dirname)) return false; return true; } else { return false; } } ?> Enjoy :) ---- Server IP: 212.24.129.51 Probable Submitter: 88.102.141.110 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/75594 Del: integrated -- https://master.php.net/note/delete/75594/integrated Del: useless -- https://master.php.net/note/delete/75594/useless Del: bad code -- https://master.php.net/note/delete/75594/bad+code Del: spam -- https://master.php.net/note/delete/75594/spam Del: non-english -- https://master.php.net/note/delete/75594/non-english Del: in docs -- https://master.php.net/note/delete/75594/in+docs Del: other reasons-- https://master.php.net/note/delete/75594 Reject -- https://master.php.net/note/reject/75594 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127265) next »