Search code examples
phpglob

php glob does not contain some strings


I have this glob

    $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);

it gets images in a images directory but some files contain the string "Insert" and "Swatch" and I dont want to return those files.

I've looked around for any example of how to exlude them from the glob but have had no luck


Solution

  • glob() can't do that. You will need to traverse the result and exclude them yourself.