|
Posted by Steve on 11/15/07 14:09
"Mike" <me@privacy.net> wrote in message
news:13jo2saj2oacnda@corp.supernews.com...
> Hi
>
> Does anyone use glob to search?. I am wondering how good/effective it is
>
> http://de3.php.net/manual/en/function.glob.php
i've been using it for years in the form of:
function listFiles($path = '.', $extension = array(), $combine = false)
{
$wd = getcwd();
$path .= substr($path, -1) != '/' ? '/' : '';
if (!chdir($path)){ return array(); }
if (!$extension){ $extension = array('*'); }
if (!is_array($extension)){ $extension = array($extension); }
$extensions = '*.{' . implode(',', $extension) . '}';
$files = glob($extensions, GLOB_BRACE);
chdir($wd);
if (!$files){ return array(); }
$list = array();
$path = $combine ? $path : '';
foreach ($files as $file)
{
$list[] = $path . $file;
}
return $list;
}
Navigation:
[Reply to this message]
|