Billy Bones
Billy Bones

Reputation: 2965

PHP `glob()` Multiple Prefixes

Ive seen several posts dealing with multiple suffixes but none with multiple prefixes. For some reason when I execute the code below it will only return those with the comp prefix.

$test = glob($dir."/{comp*, sb-*}", GLOB_BRACE);
var_dump($test);

same with this

$test = glob($dir."/{comp, sb-}*", GLOB_BRACE);
var_dump($test);

Upvotes: 2

Views: 165

Answers (1)

Mike
Mike

Reputation: 24383

The problem is the space after the comma. It is trying to match a file that starts with a space, which is almost definitely not what you want. Instead do:

$test = glob($dir."/{comp*,sb-*}", GLOB_BRACE);

Upvotes: 3

Related Questions