Page 1 of 1
Folder count in a folder, and get the names of the folders
Posted: Wed Feb 01, 2006 12:04 pm
by kaisellgren
Ciao! I've searched through PHP documentation but I couldn't find any function that will return the foldercount and the foldernames in a specified folder. I need to get the count of all folders in a folder. Then I need to know the names of those folders, ordered by desceding name order. Is there any function?
Posted: Wed Feb 01, 2006 12:14 pm
by feyd
glob() can return just directories, and can sort them, however they may not be a human logical sort. You can use
natsort() for that. As for getting the number of folders, use
count() on the return from
glob().
Posted: Wed Feb 01, 2006 12:48 pm
by pilau
Well here's something I'm going to need for my image gallery

Posted: Wed Feb 01, 2006 1:02 pm
by kaisellgren
Oh, I made it good, but there's one bug. PHP will return my folder as "../skins/ironlook", it should only return the name of the folder, ironlook. The .php is in different folder than the folders I'm counting. Hmm, any ways to remove the ../skins/ off ?
Posted: Wed Feb 01, 2006 4:21 pm
by feyd
it tries to return full pathing information. Using
basename() on each entry should get you the result you are after.