note 81692 added to function.rmdir

From: Date: Mon, 10 Mar 2008 09:25:20 +0000
Subject: note 81692 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-136888@lists.php.net to get a copy of this message
I use the following to delete a folder and all its content, and it works fine without being forced to upgrade to PHP5: function remove_dir($dir) { if(is_dir($dir)) { $dir = (substr($dir, -1) != "/")? $dir."/":$dir; $openDir = opendir($dir); while($file = readdir($openDir)) { if(!in_array($file, array(".", ".."))) { if(!is_dir($dir.$file)) @unlink($dir.$file); else remove_dir($dir.$file); } } closedir($openDir); @rmdir($dir); } } ---- Server IP: 212.124.37.9 Probable Submitter: 217.7.217.14 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/81692 Del: integrated -- https://master.php.net/note/delete/81692/integrated Del: useless -- https://master.php.net/note/delete/81692/useless Del: bad code -- https://master.php.net/note/delete/81692/bad+code Del: spam -- https://master.php.net/note/delete/81692/spam Del: non-english -- https://master.php.net/note/delete/81692/non-english Del: in docs -- https://master.php.net/note/delete/81692/in+docs Del: other reasons-- https://master.php.net/note/delete/81692 Reject -- https://master.php.net/note/reject/81692 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136888) next »