Page 1 of 1

how do i read multilines

Posted: Thu Oct 15, 2009 7:58 am
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.

Re: how do i read multilines

Posted: Thu Oct 15, 2009 8:26 am
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: