konsu wrote:try using regular expressions on each line like:
(.+)[ \t]+(good|average|excellent)[ \t]+$
does this make sense?
Sort of. But, how do I know which line I am on? For each line, I want the answer to go into a different variable and written to a different field in the database.
I was thinking of doing something like this:
#!/usr/bin/php
$dir = opendir(/home/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++) {
if ($i == "Merchandise in stock?") {
$stock1 = substr($i,56,9);
$stock1 = trim($stock1);
}
if ($i == "Advertised merchandise in stock?") {
$stock2 = substr($i,56,9);
$stock2 = trim($stock2);
}
// and so on and so on
}
}
closedir($dir);
I know my code is not correct, but that is the idea I have. Would that work?