How to get the files names from the folder using PHP ..

How to get the files names from the folder using PHP ..

am 23.10.2007 10:59:05 von Anu

Hi,

How to get the files names from the folder using PHP .. is there any
specific command.
if yes let me know that..


Thanks,
Anu

Re: How to get the files names from the folder using PHP ..

am 23.10.2007 17:19:19 von Steve

"anu" wrote in message
news:1193129945.656683.280660@k35g2000prh.googlegroups.com.. .
>
> Hi,
>
> How to get the files names from the folder using PHP .. is there any
> specific command.
> if yes let me know that..

see if this helps:

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();
foreach ($files as $file)
{
$list[] = ($combine ? $path : '') . $file;
}
return $list;
}