How to read TextArea Line by Line?

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
baoky
Forum Newbie
Posts: 12
Joined: Sat May 24, 2008 6:21 am

How to read TextArea Line by Line?

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How to read TextArea Line by Line?

Post 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>";
}
chakhar86
Forum Commoner
Posts: 45
Joined: Mon Jun 05, 2006 1:36 am
Contact:

Re: How to read TextArea Line by Line?

Post 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
Post Reply