how do i read multilines

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
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

how do i read multilines

Post by gotornot »

i have created a shopping cart and i wanted to add a mass add script.
I will use a standard form to post the data over but what comands do i use to take that data and split it up ready for insertion into the database.

I will be copy and pasting from a excel spreadsheet so im assuming its tsv.
Any help would be great.

I am looking at the explode function however how owuld that work in the scenario below:
Block A - Block B - Block C
Bob - Smith - Stinks
Fred - Jones - Clear

Is there any limit to blocks and rows and how do i start to seperate them and check them.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: how do i read multilines

Post by Eric! »

Since they are tab seperated you could try looking at this thread (last post)
viewtopic.php?f=1&t=106560&start=0&st=0 ... ilit=space
and instead of " " for space use "\t" for tab....

It is setup to convert a string like this with the KEY[space]VALUE
FIRSTNAME Joe LASTNAME blow JOB Unemployed PHONE 555-1234

You can re-arrange the parsing to match your data. Where the first line is your KEY1[tab]KEY2[tab].... and the following lines are VALUE1[tab]VALUE2[tab]....

I'm sure someone else probably has a cleaner solution though.... :wink:
Post Reply