Processing data from a text area, one line at a time

Processing data from a text area, one line at a time

am 13.09.2007 23:02:17 von mrsmithq

I am allowing the use to cut and paste comma delimited data. How do I
process the data one line at a time?

Re: Processing data from a text area, one line at a time

am 13.09.2007 23:59:29 von Jeff North

On Thu, 13 Sep 2007 14:02:17 -0700, in comp.lang.php Anthony Smith

<1189717337.618895.272990@d55g2000hsg.googlegroups.com> wrote:

>| I am allowing the use to cut and paste comma delimited data. How do I
>| process the data one line at a time?

$lines = explode("\n", $data);
for($idx=0; $idx $commas = explode(",", $lines[$idx]);
// do whatever
}

Note: you will obviously need to do more checking when exploding each
line. The data could look like:
123,"this is a line of text",123
123,"He said, 'this is a new sentence'.",123

The second example will return a length of 4.
-- ------------------------------------------------------------ -
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- ------------------------------------------------------------ -