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? Link to comment https://forums.phpfreaks.com/topic/212630-isdot-issue/ 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'; ?> Link to comment https://forums.phpfreaks.com/topic/212630-isdot-issue/#findComment-1107711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.