Re: all files in a directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 5 Sep 2003, FB wrote:

} I need a small script of php selecting all the files in a directory and
} putting the names in an array.
}
} Also, selecting a specific type might be helpfull like *.TXT

Untested:

$dir = dir('/your/dir/here');
while ($file = $dir->read()) {
  if (preg_match('/\.TXT$/i', $file)) {
     $matches[] = $file;
  }
}
$dir->close();

Your files will be in the $matches array.

/vjl/

-- 
Vince LaMonica               UC Irvine,  School  of  Social Ecology
 W3 Developer       <*>      116 Social Ecology I, Irvine, CA 92697
 vjl@uci.edu                  http://www.seweb.uci.edu/techsupport

 Tower: "Delta Zulu Romeo, turn right now and report your heading."
 Pilot: "Wilco. 341, 342, 343, 344, 345..."

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux