I am using glob to get all images from a directory. However, some of the images in the directory are thumbnails which are identified by a "-m" immediately before the file extension and I want to exclude these from the file list. So, for example there could be:
image-1.png
image-1-m.png
portrait.png
portrait-m.png
front-panel-cold.png
front-panel-cold-m.png
front-panel-warm.png
front-panel-warm-m.png
Using
foreach(glob($imdir."/*[!m].*") as $img) {
echo $img . "<br>\n";
}
I can list all the files which don't end with m, however that also excludes front-panel-warm.png. I can't find a way of escaping the hyphen:
glob($imdir."/*[!\-m].*")
gives no results,
glob($imdir."/*[!-m].*")
gives the same results as [!m] and
glob($imdir."/*[!--m].*")
excludes all files ending with any letter before n. I've also tried using a brace
glob($imdir."/*[!{-m}].*", GLOB_BRACE)
but that doesn't seem to work either.
Any ideas where I am going wrong, or is this simply something I need to use preg_match for?