Page 1 of 1

How to read TextArea Line by Line?

Posted: Thu Aug 28, 2008 9:14 pm
by baoky
How to read TextArea Line by Line?

I wanna ask about how do i read a TextArea Line by Line

e.g

my text area have 3 lines

v1234567
v1234555
v1234666

how do i get the record line by line like

when i read first line its return me v1234567

and then 2nd line return me v1234555

I would want to do it in a loop as I want to use the record in a loop

Regards and Thanks for all help.

Re: How to read TextArea Line by Line?

Posted: Fri Aug 29, 2008 2:50 am
by onion2k
Explode the form element on a carriage return to turn it into an array...

Code: Select all

$lines = explode("\n", $_POST['textarea']);
foreach ($lines as $line) {
  echo ++c." ".$line."<br>";
}

Re: How to read TextArea Line by Line?

Posted: Fri Aug 29, 2008 5:31 am
by chakhar86
is the "line feeder" from all browser is the same?
I mean, did IE send line feeder only LF(\n), as long as I know windows use CR-LF(\r\n) for line feeder, and Mac use only CR

thx