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
https://forums.phpfreaks.com/topic/179097-solved-list-dir-how-to-hide-a-folder/
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>";
}
...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.