View Single Post
Old 11-17-2008, 01:17 AM   #1 (permalink)
Peuplarchie
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application Break if no file found in directory

Good day to you,
I have a function which return an array of files.
I would need it to break if there is no file in the directory.

Here is the code :
PHP Code:
function compileList($extensions)
{
     if (
$handle opendir('.')) {
   while (
false !== ($file readdir($handle)))
      {
          
$ext strtolower(end(explode('.'$file)));
       
          if (
in_array($ext$extensions) AND $file != "." AND $file != "..")
              {
                  
$files[$file]=implode(file($file));
              }
       }
  
closedir($handle);
  }
  return 
$files;
         

Thanks !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote