Jump to content

isDot issue


webguy262

Recommended Posts

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

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

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.