How can I get sub-directory names?
You can ready the directory using read() function and drupal_realpath('public://') will give you the actual path to the public files folder.

$path = drupal_realpath('public://');
$dirs = array();
// directory handle
$dir = dir($path);

while (false !== ($entry = $dir-&gt;read())) {
    if ($entry != '.' &amp;&amp; $entry != '..') {
       if (is_dir($path . '/' .$entry)) {
            $dirs[] = $entry; 
       }
    }
}

echo '&lt;pre&gt;';print_r($dirs);echo '&lt;/pre&gt;';