09-07-2007, 01:36 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 715
Thanks: 2
|
To put glob to a slightly more practical use, in the past I've "auto-loaded" plugins as part of a framework -- if I placed a plugin file into the plugins directory then it was automatically included and available to use.
PHP Code:
// Example plugins file/folder structure:
// plugins/
// assets.php
// typography.php
//
// This would include assets.php and typography.php
// along with any other plugin files in that folder.
foreach(glob('plugins/*.php') as $szPlugin)
{
include_once $szPlugin;
}
On a more technical note, because not everyone reads the manual, it is possible to ' or' the flags for second argument if you wish to apply more than one of the available flags.
PHP Code:
// Would return files in the images folder ending with .jpg, .gif or .png
$aFiles = glob('images/{*.jpg,*.gif,*.png}', GLOB_BRACE | GLOB_NOSORT);
|
|
|
|