Current location: Hot Scripts Forums » Programming Languages » PHP » Listing folders in list box, folder only, recursively


Listing folders in list box, folder only, recursively

Reply
  #1 (permalink)  
Old 06-28-09, 04:37 PM
peuplarchie's Avatar
peuplarchie peuplarchie is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 64
Thanks: 1
Thanked 0 Times in 0 Posts
Post Listing folders in list box, folder only, recursively

Good day to you all,

I'm working on a piece of code which list directory into a dropdown box.
No problem, with that :

PHP Code:




<p>List Box - Single Select<br>
<select name="listbox" size="1">
<option  selected>Click here to see them by themes</option>
<?PHP

if ($handle opendir('themes/')) {
    while (
false !== ($file readdir($handle))) {
        if (
$file != '.' && $file != '..') {
            
$fileName str_replace('.mov'''$file);
            echo 
'<option value="' $file '">' $fileName '</option>';
        }
    }
    
closedir($handle);
}




?>

</select>
</p>


Now what I would like to do is :

1- Read the directory recursively .


Thanks !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-28-09, 06:54 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
You are not very clear on what you would like to do.

You are listing all files in a directory named themes.

Your title says you would like to list folders in a list box. But then you ask to list directory recursively(which you are doing).

Or is the problem that you are also getting directory names from inside that folder, and not just files?

If so, you can solve that problem with is_dir();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-29-09, 04:34 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Take a look at: PHP: readdir - Manual

There are LOTS of examples.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
List Everything In Folder (PHP) IKG Script Requests 14 03-22-06 04:42 AM
Revised Default Sorting Order relledge General HotScripts Site Discussion 6 09-15-05 10:50 AM
Absolutely New to VB.Net and Need a Little Help nothingofvalue Windows .NET Programming 2 07-23-05 03:56 PM


All times are GMT -5. The time now is 07:41 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.