I have the following code:
#!/usr/bin/php
<?
$dir = opendir("/Users/jeff/survey/");
while ($file = readdir($dir)) {
if(is_file($file)) {
if(!($fileArray = file($file))) {
printf("could not open $file file");
}
for ($i=0; $i < count ($fileArray); $i++) {
print "i: $i";
printf("fileArray: %s, $fileArray[$i]");
}
} else {
print "This is not a file, $file";
}
}
closedir($dir);
?>
But, it does not seem to work. Here is the output of the survey directory:
jefflaptop:~ jeff$ ls -l survey
total 16
-rw-r--r-- 1 jeff jeff 1665 Sep 7 09:36 survey.txt
jefflaptop:~ jeff$
And, here is the error message I get from that script:
This is not a file, .This is not a file, ..This is not a file, survey.txt
So, it does not think the survey.txt is a file. I am trying to read the contents of the survey.txt file so I can parse the contents and then put some of the data into a database. But, I figured I should work out one issue at a time.
Thanks,
Jeff