Php glob function

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!

This website uses cookies.