Jump to content

[SOLVED] list dir: how to hide a folder?


jerome69

Recommended Posts

Hi everyone

i have a php script that list content of a directory. But i want to hide a folder inside this list, i try some many things with no result, someone could help me  :P

Here's the code:

    <select name="folder" id="folder">
<?php
      	
	// Here we explore UploadedFiles folder and fill "select" element with names of existing folders

$d = dir_list(dirname($_SERVER['SCRIPT_FILENAME'])."/../galerie/");

	if($d) 
	{

		foreach($d as $f)
		{
			echo "<option value=\"$f\" >$f</option>";
		}
	}    
      ?>
    </select>

Thank you!

Jerome

Link to comment
Share on other sites

You should define an array containing directories that you don't want to show. Then within your foreach check to see if the current element is in that array, if it is skip that iteration using the continue keyword.

 

ex

$hide = Array('dir1', 'dir2');
...
foreach($d as $f)
{
        if(in_array($f, $hide))
                continue;
echo "<option value=\"$f\" >$f</option>";
}
...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.