Page 1 of 1

Seperating Files from Folders in a directory listing?

Posted: Thu Oct 31, 2002 12:56 pm
by Rob_Beard
Hey all.

I'd like to know how to seperate files from folders in a directory list? anyone know how to do that.

I've scoured the PHP manual until I couldnt tell a tree from a dog, but with no luck.

Posted: Thu Oct 31, 2002 1:09 pm
by seg
I don't have a direct answer for you, but these are my first thoughts on the issue.

On a server running Windows, something like exec(attrib, $list) then you can do a str function to locate directories and files since a blank attrib command echos the attributes of all directories and files in the current directory.

On a *nix machine, maybe 'cmod', or 'ls', output it to a variable then search the variable for the right chmod flags.

Like i said, its not a solid answer, but I hope its heading in the right direction.

Posted: Thu Oct 31, 2002 2:54 pm
by volka

Posted: Thu Oct 31, 2002 3:36 pm
by seg

search for "."

Posted: Mon Nov 04, 2002 8:50 pm
by sad2891
all i did when i needed to do that was search for a period in the filename, if it was a folder it didnt have one and if it was a file it did (to seperate the file extension). And if you wanted to, you could use regex to make it more precise.

Re: search for "."

Posted: Tue Nov 05, 2002 2:10 am
by twigletmac
sad2891 wrote:all i did when i needed to do that was search for a period in the filename, if it was a folder it didnt have one and if it was a file it did (to seperate the file extension). And if you wanted to, you could use regex to make it more precise.
Erm, is_file() and is_dir() are the really simple way of doing this as volka pointed out.

Mac