| 
	
 | 
 Posted by Steve on 10/23/07 15:19 
"anu" <anunanni2006@gmail.com> 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; 
}
 
  
Navigation:
[Reply to this message] 
 |