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
Explode textarea separated by newline
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
try
that's the only thing that I can thing of
Code: Select all
$textarea = nl2br($_POST['txtA']);
explode("<BR />", $textarea);- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
I had to do this to make it work correctly.
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
Code: Select all
$lines = explode("<br>",str_replace("\n","<br>",$_POST['txtA']));I once saw another thread regarding this - he too had the same problem - he had to replace \n with something to explode.
Thanks