Search code examples
phpfilenamesdesign-patternsglob

glob() and asterisks in curly brackets


I want to find some special filenames. Therefore I use glob().

$foundResults = glob($directory . '{data_*.csv, log_*.txt}', GLOB_BRACE);

This code only finds my first pattern data_*.csv. So it seems that an asterisks is not allowed in between the curly brackets?

What are my alternatives? I can only think of using a for each construct to call glob() multiple times. Or are there better algorithms/functions?


Solution

  • Correct call without the space characters!

    $foundResults = glob($directory . '{data_*.csv,log_*.txt}', GLOB_BRACE);
    

    I got the tip from this topic: help with glob/GLOB_BRACE