Page 1 of 1
Explode textarea separated by newline
Posted: Fri Mar 18, 2005 6:33 am
by anjanesh
I have <textarea name="txtA"></textarea>
$lines = explode("\n",$_POST['txtA']); doesnt seem to split into lines. I tried \r\n to but still $lines is still a string and not an array.
Any solutions ?
Thanks
Posted: Fri Mar 18, 2005 7:16 am
by Chris Corbyn
Seems odd.. could you post a bit more code?
Posted: Fri Mar 18, 2005 8:00 am
by s.dot
try
Code: Select all
$textarea = nl2br($_POST['txtA']);
explode("<BR />", $textarea);
that's the only thing that I can thing of
Posted: Fri Mar 18, 2005 8:02 am
by n00b Saibot
what is the output if you print it directly. does it have new-lines in them

Posted: Fri Mar 18, 2005 10:12 am
by anjanesh
I had to do this to make it work correctly.
Code: Select all
$lines = explode("<br>",str_replace("\n","<br>",$_POST['txtA']));
Saibot - On printing it directly it'll print with \n in the html source - obviously it'll be linear in the output - dont know why explode could not use \n as separator.
I once saw another thread regarding this - he too had the same problem - he had to replace \n with something to explode.
Thanks