php - negative pattern matching to exclude certain files using glob -
i using glob images directory. however, of images in directory thumbnails identified "-m" before file extension , want exclude these file list. so, example there 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].*") $img) { echo $img . "<br>\n"; }
i can list files don't end m, excludes front-panel-warm.png. can't find way of escaping hyphen:
glob($imdir."/*[!\-m].*")
gives no results,
glob($imdir."/*[!-m].*")
gives same results [!m] ,
glob($imdir."/*[!--m].*")
excludes files ending letter before n. i've tried using brace
glob($imdir."/*[!{-m}].*", glob_brace)
but doesn't seem work either.
any ideas going wrong, or need use preg_match for?
use exclude files ending -m
foreach(glob($imdir."/*[!-]?[!m]?.png") $img) { echo $img . "<br>\n"; }
Comments
Post a Comment