note 13720 deleted from function.rmdir by jimw

From: Date: Wed, 02 Jan 2002 01:28:54 +0000
Subject: note 13720 deleted from function.rmdir by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24094@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

« previous php.notes (#24094) next »