note 81844 added to function.rmdir

From: Date: Sun, 16 Mar 2008 00:33:29 +0000
Subject: note 81844 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-137091@lists.php.net to get a copy of this message
This is another deltree function version from boccheciampe (and lukas and first one from vboedefeld) Notice that I put the rmdir sentence out of the foreach loop. In the boccheciampe version the rmdir was in the foreach loop and I think that it's an error because it tries to delete the same directory on every loop. And this version propagates the result of the operation for a better control of it. function esborrar_directori($ruta) { if (!empty($ruta) && $ruta != '.' && $ruta != '..' ) { if (is_dir($ruta)) { foreach(glob($ruta.'/*') as $node) { if (is_dir($node) && !is_link($node)) $swOK = ($node == '.' || $node == '..' || esborrar_directori($node)); else $swOK = unlink($node); if (!$swOK) return false; } return rmdir($ruta); } } return false; } ---- Server IP: 130.206.1.5 Probable Submitter: 87.221.106.144 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/81844 Del: integrated -- https://master.php.net/note/delete/81844/integrated Del: useless -- https://master.php.net/note/delete/81844/useless Del: bad code -- https://master.php.net/note/delete/81844/bad+code Del: spam -- https://master.php.net/note/delete/81844/spam Del: non-english -- https://master.php.net/note/delete/81844/non-english Del: in docs -- https://master.php.net/note/delete/81844/in+docs Del: other reasons-- https://master.php.net/note/delete/81844 Reject -- https://master.php.net/note/reject/81844 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137091) next »