How do you find out what are directories when you list out a directory? I am listing out the contents of a directory which includes another directory.
Is there a way of removing any directories from the listing? Or at least distinguishing what are files and dirctories?
Cheers Dave
for each file u read check against is_dir() function
syntax: bool is_dir (string filename)
Returns true if the filename exists and is a directory
to remove a directoey use function :
int rmdir (string dirname)
Attempts to remove the directory named by pathname. The directory must be empty, and the relevant permissions must permit. this.
Whoa there, this will DELETE the directory, not just hide it from the listing.
Just use a string-comparison to see if the current file/dir has the name of what you want to hide.
yeh this is fine if i know the name of the directory but i would like to be able to check to see what directories there are so i can view the contents of the directories.
Is this possible?
Im new to this as well so idiots guide would be great stuff 🙂
Like vandana said, that's what the "is_dir()" is for.
Search the forum, there have been posts about doing a "recursive directory listing"
Definitely have a look at both the directory and file access functions, as they have a lot of cross over, as in the is_dir command and the mkdir command.
I'll post a code frag right now (just made it) that does a recursive directory listing. It'll be in the filesystem utilities area.
http://www.phpbuilder.com/snippet/detail.php?type=snippet&id=204
thankyou very much this is exactly what i need!
And thank you everyone for your help, most kind 🙂
Thanx a lot. I was looking for exactly the same, too. Great recursive code.