Page 1 of 1

Reading and seperating data in a text file

Posted: Tue Feb 20, 2007 11:23 am
by keveh
I was wondering what the best way around this problem would be, if at all possible.

Say I have a mysql database with the fields in a table being:

Name
Number
Address

If my .txt file was layout like this:

Code: Select all

Keveh, 456789, 13 House
Paul, 34567, 45 Flat
John, 12345, 10 Apartment
Is there a way of putting all this information in to an array and picking out each piece that is seperated with a comma so that I can generate an insert mysql query?

Posted: Tue Feb 20, 2007 11:37 am
by Luke
a few...

explode()
fgetcsv()

are a few I can think of...