There is a problem on this script. If there are no files in the dir
then I get an error. That is why the if
size of ($FILES)>0) test ***** It should sort and do the for each
loop but it ignores that test. I also have the if($claim_file) test
and that doesn't work either. Should I try if is empty($claim_file)?
This code also runs through the loop only once even if there are more
than one claim files. Is that because the for each does not need the
while (!feof($clm_file)) since it would stop at the last processed
file?
thanks,
##try{
$dir = "../clm_stuff/";
$archive_dir = "../clm_test/";
$bad_dir = "../clm_bad/";
# FOR EACH FILE IN A GIVEN DIRECTORY:
$dir_handle = opendir($dir);
while (false !== ($file = readdir($dir_handle))) {
# OPEN FILE
if(($file!='.')&&($file!='..')&&($file!='.ftpquota ')){
$FILES[] = $file;
}
}
#closedir($dir_handle);
if(sizeof($FILES)>0){ ***********
sort($FILES);
foreach($FILES as $file){
$clm_file = fopen($dir.$file, "r");
print $file."<BR>";
if $clm_file { ****
# FOR EACH LINE:
while (!feof($clm_file)) {
# PARSE ACCORDING TO COMMA DELIMITED
Some code that works here!
}
}
}
}
}