webguy262 Posted September 6, 2010 Share Posted September 6, 2010 trying to exclude . and .. files from a dir listing and getting Fatal error: Call to undefined function isDot() with the follwing code $files = scandir($dir); $counter = 0; foreach($files as $file) { if (!$files->isDot()) { echo $file; $counter++; } } I'm a bit buzzed so I prob should not be working but... ...what am I missing? Quote Link to comment Share on other sites More sharing options...
objnoob Posted September 6, 2010 Share Posted September 6, 2010 isDot is a method of the DirectoryIterator class. You must instantiate an object of this class before using its method. <?php $count = 0; $files = new DirectoryIterator('C:\\'); foreach($files as $file) { if (!$files->isDot()) { echo $file->getFilename().'<br />'; $count++; } } echo 'There is '.$count.' files'; ?> 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.