PHP Reading folders and files

Hi All,

Disclaimer: PHP newbie

I’m using a similar piece of code to read all the files in a certain web server directory into a long variable text string. Then I use loadvars to import into Flash and read into an array.


/* Returns the filenames from the directory */
<?
$dir = opendir("flash_1");
$i = 1;
while($file = readdir($dir))
if(is_file($file))
echo "&file". $i . "=" . $file;
?>

I understand the code above, but don’t know the objects/functions to use to read folder names in PHP. Instead of reading file names, I would like to read all of the folder names inside a folder. For example, how would I write a PHP loop to return all the artist name folders inside a folder called music?

music
artist folder names (nested inside music folder)