note 77476 added to function.rmdir

From: Date: Fri, 31 Aug 2007 00:21:32 +0000
Subject: note 77476 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-129922@lists.php.net to get a copy of this message
Here's my stack-based pseudo-recursive rmdir. It borrows heavily from andy at mentalist's. <?php function rmdir_r($path) { if (!is_dir($path)) {return false;} $stack = Array($path); while ($dir = array_pop($stack)) { if (@rmdir($dir)) {continue;} $stack[] = $dir; $dh = opendir($dir); while (($child = readdir($dh)) !== false) { if ($child[0] == '.') {continue;} $child = $dir . DIRECTORY_SEPARATOR . $child; if (is_dir($child)) {$stack[] = $child;} else {unlink($child);} } } return true; } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 64.105.153.106 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/77476 Del: integrated -- https://master.php.net/note/delete/77476/integrated Del: useless -- https://master.php.net/note/delete/77476/useless Del: bad code -- https://master.php.net/note/delete/77476/bad+code Del: spam -- https://master.php.net/note/delete/77476/spam Del: non-english -- https://master.php.net/note/delete/77476/non-english Del: in docs -- https://master.php.net/note/delete/77476/in+docs Del: other reasons-- https://master.php.net/note/delete/77476 Reject -- https://master.php.net/note/reject/77476 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129922) next »