Jump to content

Excluding hidden files


neridaj

Recommended Posts

Hello,

 

I'm having problems figuring out how to exclude hidden files when building an image array. I'm using a regex to validate the image, should I use another regex for hidden files instead of strtok()?

 

function get_after_thumbs()
{
$dir = get_dir();
$afterdir = $dir . 'after/thumbs/';
$files = scandir($afterdir);
foreach($files as $value) {
	// check for image files
	if(valid_image_file($value))
		if(!strtok($value, '._'))
		// build image array
		$imgarr[] = $value;
}
$count = count($imgarr);
for ($i=0; $i<$count; $i++) {
	echo '<img class="floatright" src="' . $dir . 'after/thumbs/' . $imgarr[$i] . '" width="25" height="25" alt="09 285" />';
}
var_dump($imgarr);
}

 

Thanks,

 

Jason

Link to comment
https://forums.phpfreaks.com/topic/120932-excluding-hidden-files/
Share on other sites

 

function get_after_thumbs()

{

$dir = get_dir();

$afterdir = $dir . 'after/thumbs/';

$files = scandir($afterdir);

foreach($files as $value) {

if( substr($value, 0, 1 ) == "." )

  continue;

 

 

// check for image files

if(valid_image_file($value))

if(!strtok($value, '._'))

// build image array

$imgarr[] = $value;

}

$count = count($imgarr);

for ($i=0; $i<$count; $i++) {

echo '<img class="floatright" src="' . $dir . 'after/thumbs/' . $imgarr[$i] . '" width="25" height="25" alt="09 285" />';

}

var_dump($imgarr);

}

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.