Excluding hidden files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neridaj
Forum Commoner
Posts: 40
Joined: Fri Jan 05, 2007 9:55 pm

Excluding hidden files

Post by neridaj »

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()?

Code: Select all

 
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
Post Reply