![]() |
Read Directory Function
Most of you developing websites or having portfolios, this function may come in use in your PHP endeavors.
Example: Directory Quick Browse Script Added Note: If you're using anything less than php version 5.0.2, or you're getting an error using the code, add this in as well. PHP Code:
PHP Code:
PHP Code:
|
Theres a better way to escape the two periods
PHP Code:
|
I don't really see how that code is "better"..? It's pretty much the same thing..
|
Quote:
|
As opposed to two ;) Not much of a difference, but thank you for the pointer :)
|
Quote:
|
Just a friendly tip, check out the glob function :-)
|
Quote:
|
Glob! I just fell in love with the glob function as soon as I stumbled across it.
|
Glob will only return files of a certain extension, and supports only two arguments though.. This does an entire directory + sub directories :D
|
didn't want to create a new thread because the topic is really similar.
I was trying to make a recursive function just to count how many files are in a dir and it's subdirectories: PHP Code:
I saw that CHASE in his code put all the directories in a array and then called the recursive function, but it should work without using the array I think... Aah I posted twice, please delete it admins :) |
I would recommend using the function I built, and then just removing the echos, and having it $var++
That would probably do what you want :) |
Not to be a stickler but ++$var is faster then $var++
|
Oh cool, I didn't know that, thanks for the tip.
|
Quote:
Quote:
glob will return whatever you tell it to return. If you just specify * as the pattern, glob will return all files and directories in the current working directory. It's simple enough to check for directories and go through each recursively, as you do in your own code. |
Quote:
Just want to know what is wrong there... ^^ |
| All times are GMT. The time now is 08:37 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0