listing folders one level up in a select value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

listing folders one level up in a select value

Post by andylyon87 »

hey guys this is kind of an extension to what i submitted before. Am confused why this doesnt work.

The code below is ripped and edited from my last problem which was solved using a variant of this.

Code: Select all

printdir('/*');


function printdir($path) {
        
        echo "<select name=selection>";
        foreach( glob($path.'/*') as $e ) {
        	
                if ( is_dir(basename($e)) ) {
                	
                         echo "<option value=\"$e\">", basename($e), "- $e</option><br />";//displays file and path
                }
        
        }
        echo "</select>";
        
}
what I want it to do is check for files and see if they are directories, then only show the directories in the select list. unfortunately this seems to be showing nothing. If I stick a ! infront of the is_dir it decides to show everything all the directories and files

thanks

Andy
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try

Code: Select all

printdir('..');
Post Reply