problem with is_dir()
Posted: Fri Sep 29, 2006 11:31 am
feyd | Please use
My problem is that this code WILL display also directories. Not all of them, though, it will skip just one (I think it's the first one).
So in a directory where I have 2 files and 3 dirs, I get in the select box the 2 files and 2 dirs.
What am I missing here?
Many thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I have this strange problem with the is_dir() function.
I have a piece of code that will loop through all files in a certain directory and will put only regular files (i.e. no dircetories) in a select drop down.
Here's my code:Code: Select all
echo "<tr><td><select name='dFile'>";
if ( $dDir = @openDir($rootDir) )
{
while ( ($dFile = @readDir($dDir)) !== FALSE )
{
if ( $dFile == "." || $dFile == ".." || is_dir($dFile) )
continue;
echo "<option value='$rootDir/$dFile'>$dFile";
}//while
closedir($dDir);
}//if
echo "</select></td></tr>";So in a directory where I have 2 files and 3 dirs, I get in the select box the 2 files and 2 dirs.
What am I missing here?
Many thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]