Some variation of the below is what i would use. YMMV depending on what youre doing. If you post your code we can address your specific implementation instead of jsut providing alternate solutions :-)
$dir = new DirectoryIterator('/path/to/states');
foreach($dir as $file)
{
if(!$file->isDot() && $file->isFile() && strpos($file->getFilename(), '.txt') !== false)
{
$content = file_get_contents($file->getPathname());
if($content)
{
// do your insert code
}
}
}
prodigitalson
2010-01-26 21:31:05