TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-30-2010, 09:28 PM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application List as array and modify the input

Good day to you all,
here I have a recursive directory lister that puts everything into an array.

Here is the code:

PHP Code:


<?
function getDirectory($path '.'$ignore '') {
    
$dirTree = array ();
    
$dirTreeTemp = array ();
    
$ignore[] = '.';
    
$ignore[] = '..';

    
$dh = @opendir($path);

    while (
false !== ($file readdir($dh))) {

        if (!
in_array($file$ignore)) {
            if (!
is_dir("$path/$file")) {
                
                
$dirTree["$path"][] = $file;
                
            } else {
                
                
$dirTreeTemp getDirectory("$path/$file"$ignore);
                if (
is_array($dirTreeTemp))$dirTree array_merge($dirTree$dirTreeTemp);
            }
        }
    }
    
closedir($dh);
    
    return 
$dirTree;
}

$ignore = array('.htaccess''error_log''cgi-bin''php.ini''.ftpquota');

$dirTree getDirectory('Photos'$ignore);
?>
<pre>
    <?
    print_r
($dirTree);
    
?>
</pre>

My question is how can I keep the same array and without looping again through the directories again list only the folder ?

If i can, how can I also list a text only the folder that does have folder in them and as a link the one that as files.

So when a link is press I can list the array under that folder

Thanks!
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Type Juggling/Type Casting to Modify Data Types Wildhoney Tips & Tricks 6 11-30-2007 02:44 AM


All times are GMT. The time now is 03:44 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design