src/DirHelper.php
public static function isDirEmpty(string $path) : bool
    {
        //che if no such dir, not a dir, not readable
        if (!self::isReadable($path)) {
            return false;
        }

        $result = true;
        $handle = opendir($path);
        while (false !== ($entry = readdir($handle))) {
            if (!self::isDotDir($entry)) {
                $result = false;
                break;
            }
        }
        closedir($handle);
        return $result;
    }
public static function isDirEmpty(string $path) : bool
    {
        //che if no such dir, not a dir, not readable
        if (!self::isReadable($path)) {
            return false;
        }

        $result = true;
        $handle = opendir($path);
        while (false !== ($entry = readdir($handle))) {
            if (!self::isDotDir($entry)) {
                $result = false;
                break;
            }
        }
        closedir($handle);
        return $result;
    }
public static function isDirEmpty ( string $ path ) : bool { //che if no such dir, not a dir, not readable if ( ! self :: isReadable ( $ path ) ) { return false ; } $ result = true ; $ handle = opendir ( $ path ) ; while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( ! self :: isDotDir ( $ entry ) ) { $ result = false ; break ; } } closedir ( $ handle ) ; return $ result ; }
Check if a directory is empty in efficent way.
Check hidden files too.
@param string $path
@return bool
Check if a directory is empty in efficent way . Check hidden files too .