note 59036 deleted from function.rmdir by aidan

From: Date: Wed, 15 Apr 2009 04:28:19 +0000
Subject: note 59036 deleted from function.rmdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153269@lists.php.net to get a copy of this message
Note Submitter: stefano at takys dot it ---- becouse all the examples fails if there are hiddenfiles (.filename) somewhere, I write this short and power function to erase a tree independtly from his content /** * rm() -- Very Vigorously erase files and directories. Also hidden files !!!! * * @param $dir string * be carefull to: * if($obj=='.' || $obj=='..') continue; * if not it will erase all the server...it happened to me ;) * the function is permission dependent. */ function rm($dir) { if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) rm($dir.'/'.$obj); } @rmdir($dir); }

« previous php.notes (#153269) next »