Jump to content

Odd, directory read issue...


iPixel

Recommended Posts

Here's my directory read code..

$dir = "renamed/";
$fileCount = 0;


// Open the directory, and proceed to read its contents
if (is_dir($dir))
	{
	if ($dh = opendir($dir)) 
		{
			while (false !== ($file = readdir($dh)))
				{
					$fileCount++;
					echo $file . "<BR>";
				}
			closedir($dh);
		}
	}

 

That part works 99%, for some reason the echo $file . "<BR>"; part echos two weird things.

A singe dot and two dots as displayed below.

 

R_334499.jpg

R_334488.jpg

R_334510.jpg

R_334479.jpg

R_334494.jpg

R_334476.jpg

R_334480.jpg

R_334507.jpg

R_334482.jpg

R_334489.jpg

R_334498.jpg

..

R_334509.jpg

R_334511.jpg

R_334513.jpg

R_334483.jpg

R_334514.jpg

R_334484.jpg

R_334504.jpg

R_334506.jpg

R_334475.jpg

R_334502.jpg

R_334490.jpg

R_334486.jpg

R_334477.jpg

R_334492.jpg

R_334487.jpg

R_334493.jpg

.

R_334496.jpg

R_334500.jpg

R_334485.jpg

R_334497.jpg

R_334491.jpg

R_334481.jpg

R_334508.jpg

R_334505.jpg

R_334501.jpg

R_334503.jpg

R_334495.jpg

R_334478.jpg

R_334512.jpg

 

Any idea where it's getting the  ..    and the    .        from?

Link to comment
https://forums.phpfreaks.com/topic/224191-odd-directory-read-issue/
Share on other sites

How can i avoid $file containing such a thing, i want to use those filenames to do other things with them, and clearly a file named ..  and  .  will not be found.

I guess i could just check if $file == "." skip it but i'm just curious if there's a way around this.

 

Thanks!

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.