I've got a small php script that will gather all files in a directory. Futhermore, I'm cleaning through this array of names to skip over the ones I don't want:
$dirname = "./_i开发者_C百科mages/border/";
$border_images = scandir($dirname);
$ignore = Array(".", "..");
foreach($border_images as $border){
if(!in_array($border, $ignore)) echo "TEST".$border;
}
This directory would contain images that I want to find. Amongst these images, there will be a thumbnail version and a full-size version of each image. I'm planning to have each image either labeled *-thumbnail or *-full to more easily sort through.
What I'm trying to find is a way to, preferably with the $ignore array, add a wildcard string that will be recognized by a check condition. For example, adding *-full in my $ignore array would make that files with this tag, anywhere in their filenames, would be ignored. I'm pretty sure the in_array wouldn't accept this. If this isn't possible, would using regular expressions be possible? If so, what would my expression be?
Thanks.
You're probably looking for php's function glob()
$files_full = glob('*-full.*');
There is a better way to do this known as glob()
.
Take a look at glob
function.
glob — Find pathnames matching a pattern
精彩评论