technically the file can be read either way. I'd imagine it would be an issue to re-format the text file so your solution is to read the text file line by line, building up SQL insert statements and executing them.
// to read the text file line by line using fgets ...
// note: Returns a string of up to length - 1 bytes read from the file pointed to by handle. Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, the length defaults to 1k, or 1024 bytes.
$handle = fopen("/tmp/inputfile.txt", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
// if the text file was in csv format using @fgetcsv ...
$fp = @fopen($_FILES['csvfile']['tmp_name'], "r") or die ("Cannot open file on server");
while(!@feof ($fp)) {
$row=@fgetcsv($fp, 1024, ",");
}
fclose($fp);