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




"anu" <anunanni2006@xxxxxxxxx> wrote in message
news:1193129945.656683.280660@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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;
}


.



Relevant Pages

  • Re: Alternative to ADIR() functions
    ... >> particular folder into an array. ... I then append the names in the array ... >> ADIR function. ... >> command in a DOS window. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: [PHP] returning array from commandline
    ... array for use within the web interface. ... Exactly - the array is a PHP construct, once you've called the command ...
    (php.general)
  • Alternative to ADIR() functions
    ... I am using the ADIR function to read the names of all picture files in a ... particular folder into an array. ... I then append the names in the array into ... command in a DOS window. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: [PHP] cant get output of exec (nice -n 19 ffmpeg -i "file")
    ... $ret (or whatever you name the second parameter of exec()) will ... always be an array, regardless of the actual output from the command. ...
    (php.general)
  • Re: [PHP] returning array from commandline
    ... I.e. if its an array dont echo it, return it rather and im have huge ... use the array after the commandline tool has been run. ... Exactly - the array is a PHP construct, once you've called the command ...
    (php.general)