Reading and seperating data in a text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
keveh
Forum Commoner
Posts: 27
Joined: Mon Aug 08, 2005 5:50 am

Reading and seperating data in a text file

Post 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?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

a few...

explode()
fgetcsv()

are a few I can think of...
Post Reply