Jump to content

Read a file to write in other file or database?


sovandy

Recommended Posts

Dear everyone here!

 

I need your help very soon. I wanna read a .txt file that has many records and lines. I have to generate that record into database. in each lines that need to be entered to field of database are separated by tab.

Please see my code:

$original = fopen("test.txt","r+");
//$new_file = fopen("query.txt","w");

while(!feof($original))
{
$line = fgets($original);
$token = strtok($line, "	"); 
while ($token != false){
	$comma_line = $comma_line.", ";
	$token = strtok("	");
}
//$query_line = "insert into my_table ('')";

}
fclose($original);

 

I do hope to get your help soon.

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.