note 13720 added to function.rmdir.php

From: Date: Fri, 29 Jun 2001 19:22:48 +0000
Subject: note 13720 added to function.rmdir.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-14775@lists.php.net to get a copy of this message
Philipp suggested this: To remove whole directories that are not empty, use this: $dir = "x"; // (replace x with the directory name) $handle = opendir($dir); while($file = readdir($handle)) if($file != "." && $file != "..") unlink($dir . "/" . $file); closedir($handle); rmdir($dir); Philipp which works great, but is a bit tough to read. The following simply has the proper syntax(minus indentation, sorry): $dir = "listings/$fileName/images/"; $handle = opendir($dir); while($file = readdir($handle)) { if($file != "." && $file != "..") { unlink($dir . "/" . $file); } } closedir($handle); rmdir($dir); -Paul http://www.php.net/manual/en/function.rmdir.php

« previous php.notes (#14775) next »