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.
Seperating Files from Folders in a directory listing?
Moderator: General Moderators
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.
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.
search for "."
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.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: search for "."
Erm, is_file() and is_dir() are the really simple way of doing this as volka pointed out.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.
Mac