Afficher un message
Vieux 13/09/2007, 22h59   #2
Jeff North
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Processing data from a text area, one line at a time

On Thu, 13 Sep 2007 14:02:17 -0700, in comp.lang.php Anthony Smith
<mrsmithq@hotmail.com>
<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<count($lines); $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
-- -------------------------------------------------------------
  Réponse avec citation
 
Page generated in 0,05791 seconds with 9 queries