iPixel Posted January 12, 2011 Share Posted January 12, 2011 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? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 12, 2011 Share Posted January 12, 2011 Those represent the current directory, and the directory above the current directory Quote Link to comment Share on other sites More sharing options...
iPixel Posted January 12, 2011 Author Share Posted January 12, 2011 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! Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 12, 2011 Share Posted January 12, 2011 just check if $file == "." skip it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.