![]() |
|
|
|||||||
![]() |
|
|
Thread Tools |
Rating:
|
|
|
PM User | #1 |
|
Senior Coder ![]() ![]() Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Recursive Directory Listing (Show full directory structure)
This function will read the full structure of a directory. It's recursive becuase it doesn't stop with the one directory, it just keeps going through all of the directories in the folder you specify.
PHP Code:
PHP Code:
http://www.php.net/opendir http://www.php.net/readdir http://www.php.net/closedir http://www.php.net/in-array http://www.php.net/str-repeat http://www.php.net/is-dir
__________________
PHP Weekly - A PHP Developers Resource PHP 5.1.4 and Ruby on Rails web hosting Moderator of PHP and Work offers and Requests Install Apache/PHP/MySQL (by marek_mar) | TinyPlugin Architecture |
|
|
|
|
|
PM User | #4 |
|
New Coder ![]() Join Date: Jan 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
sorry but this doesn't work on my php server.. I NEED HELP lol.. if i want to show a directory /public_html/flash/ what do i have to put? and what is the "level" variable about??
thanx. Jamez. |
|
|
|
|
|
PM User | #6 |
|
Sensei ![]() ![]() Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
![]() |
This function does the same thing but is a _LOT_ faster:
PHP Code:
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider. Experience is something you get just after you really need it. PHP Installation Guide Feedback welcome. |
|
|
|
|
|
PM User | #8 |
|
Regular Coder ![]() Join Date: Jan 2005
Posts: 153
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Peuplarchie, did you actually call the function or did you just copy/paste the code from above into your php page? Because you have to include the above code in <?PHP and ?> and then actually call it inside the php tags like so:
PHP Code:
|
|
|
|
|
|
PM User | #10 |
|
New to the CF scene Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Not being sniffy, should probably rewrite/repost myself: but the function is both getting the directory listing and printing the result, would be nice if it returned the data from the recursive directory scan (probably in an array) so programmer can specify how it is shown, either print or send to HTML template etc. keep functions doing one thing, getting data from filesystem or printing the result makes it more re-usable.
|
|
|
|
|
|
PM User | #11 |
|
New to the CF scene Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
PHP Code:
|
|
|
|
|
|
PM User | #12 |
|
New to the CF scene Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
The getDirectory function is totally awesome! and exactly what i needed. here's the thing tho: when i was hacking it up on my dev box it was working great. but then, once i got it the way i wanted it, i uploaded the files to the web server, and now everything is coming up in random order.
is there a way to force it to read alphabetically? Is is my web server? is it something else entirely? anybody know of this issue?TIA ~joel |
|
|
|
|
|
PM User | #13 |
|
New to the CF scene Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
The getDirectory function is totally awesome! and exactly what i needed. here's the thing tho: when i was hacking it up on my dev box it was working great. but then, once i got it the way i wanted it, i uploaded the files to the web server, and now everything is coming up in random order.
is there a way to force it to read alphabetically? Is is my web server? is it something else entirely? anybody know of this issue?TIA ~joel Here's my code: PHP Code:
|
|
|
|
|
|
PM User | #14 |
|
New to the CF scene Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
graphical recursive directory lister
PHP Code:
Last edited by Fou-Lu; 10-11-2009 at 06:26 AM.. |
|
|
|
|
|
PM User | #15 |
|
New to the CF scene Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Hi,
This script works pretty well except that the files list is not ordered. I'd like to sort it alphabetically. Any idea how to do that? For example, I got this: 0012.jpg 0011.pdf 0024.pdf 0004.jpg 0018.pdf 0008.pdf While I'd like to get this: 0004.jpg 0008.pdf 0011.pdf 0012.jpg 0018.pdf 0024.pdf Thanks for any help. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|