note 98231 deleted from function.is-dir by danbrown

From: Date: Thu, 03 Jun 2010 13:15:57 +0000
Subject: note 98231 deleted from function.is-dir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169849@lists.php.net to get a copy of this message
Note Submitter: max ---- Here's my flavor of checking if a directory is empty based on what I have seen here. <?php function is_empty_directory($full_path) { //If the path is not a directory, then it is not an empty directory. if(!is_dir($full_path)) { return FALSE; } //Look through the directory for files. $directory_handle = opendir($full_path); while(($file_name = readdir($directory_handle)) !== FALSE) { //If we found a real file. if($file_name != '.' && $file_name != '..') { //The directory is not empty. return FALSE; } } //The directory is empty. return TRUE; } ?>

« previous php.notes (#169849) next »