Maybe it’s common use and everybody but me already knew it, but after ten years of php development, I’ve just find a very useful php function: Glob.

Glob function can be used to return an array of files from a given path, where file names matches a pattern.

Per example, if you need to find all files whose name begins with form- you just have to use:

$array = glob( './form-*' );

Or inside a loop to do something on each of these file:

foreach( glob( './form-*' ) as $file )
{
      // do what you want. 
}

Proof that we learn everyday!


React to this article!

Did I miss something? I'd really liked to know your though about this.
If you like this article, please 📣 share-it!

You can also follow me on my blog, on Medium, and reach me via Twitter and LinkedIn

Leave a Reply