neridaj Posted August 22, 2008 Share Posted August 22, 2008 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 More sharing options...
AjBaz100 Posted August 23, 2008 Share Posted August 23, 2008 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); } Link to comment https://forums.phpfreaks.com/topic/120932-excluding-hidden-files/#findComment-623523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.