Checking if a folder is empty or not using PHP

Checking if a folder is empty or not using PHP

Page 1 of 1

1 Replies - 698 Views - Last Post: 12 February 2010 - 06:58 AM Rate Topic: -----

#1 Guest_Eliza Sahoo*


Reputation:

Checking if a folder is empty or not using PHP

Posted 12 February 2010 - 02:55 AM

The codes given below will explain this:
/**
 * Checking a folder is empty or not.
 * @param string $folderName
 * $folderName should be folder name or path
 * @return TRUE/FALSE (If any file or folder found/Empty folder)
 * By: Subhranil Dalal
 */
 
 
function checkFolderIsEmptyOrNot ( $folderName ){
    $files = array ();
    if ( $handle = opendir ( $folderName ) ) {
        while ( false !== ( $file = readdir ( $handle ) ) ) {
            if ( $file != "." && $file != ".." ) {
                $files [] = $file;
            }
        }
        closedir ( $handle );
    }
    return ( count ( $files ) > 0 ) ?  TRUE: FALSE;
}

This post has been edited by JackOfAllTrades: 12 February 2010 - 07:00 AM
Reason for edit:: Removed link & email address. Added code tags.


Is This A Good Question/Topic? 0

Replies To: Checking if a folder is empty or not using PHP

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,217
  • Joined: 23-August 08

Re: Checking if a folder is empty or not using PHP

Posted 12 February 2010 - 06:58 AM

Eliza, your posts here are really just spam for your offshoring company. Please stop...we will continue to remove your self-promotion.

EDIT: Not to mention the code is inefficient, but what else should we expect from someone spamming their Indian body shop.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1