User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,509 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,661 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 570 | Replies: 1
Reply
Join Date: Dec 2005
Posts: 22
Reputation: magikman is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
magikman magikman is offline Offline
Newbie Poster

Display all directories at links

  #1  
Sep 26th, 2007
Hello,

I am trying to create a small php script that will display all but a few directories on my server as links. I have created the following code. I had it working when trying to ignore one directory, but now i would like to place the ignored directories within an array and ignore them that way. I am receiving the following error:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /WWW/it461.dvterry.com/index.php on line 31

Code:
<?php
function listdirs($dir)
{
        static $alldirs = array();
        $dirs = glob($dir . '/*', GLOB_ONLYDIR);
        if (count($dirs) > 0)
        {
                foreach ($dirs as $d) $alldirs[] = $d;
        }

        foreach ($dirs as $dir) listdirs($dir);
        return $alldirs;
}
$ignoreArray = array("./test","./Homework_2");
?>

<html>
<head>
<title>
Main
</title>
</head>
<body>
<?php

        foreach(listdirs('.') as $dir)
        {
                if (!in_array($dir, $ignoreArray))
//              if ( $dir != "./Homework_2");
                {
                        echo "<a href="$dir">"$dir"</a><br />";
                }

        }
?>
</body>
</html>

Thanks!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 22
Reputation: magikman is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
magikman magikman is offline Offline
Newbie Poster

Re: Display all directories at links

  #2  
Sep 26th, 2007
Got it. Removing the double quotes in the href fixed it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:47 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC