Portal Home > Knowledgebase > Articles Database > Exploding new lines PHP.
Exploding new lines PHP.
|Posted by Research Names, 01-06-2011, 02:00 AM|
|I am using the following code to explode new lines in form input but each array item has a trailing new line. I have tried trimming by \r, \n but no luck.
$f_choices = @explode("\n", $choices[$k]);
|Posted by squirrelhost, 01-06-2011, 02:53 AM|
|very odd, but you could instead try:
$f_choices = preg_split("/[\r\n]+/", $choices[$k]);
|Posted by GGWH-James, 01-06-2011, 04:24 AM|
|TEXTAEREAs use both carriage returns and new lines. Have you tried:
Last edited by GGWH-James; 01-06-2011 at 04:28 AM.
|Posted by Research Names, 01-06-2011, 06:04 AM|
|From the HTML specification I was sure that CRs weren't allowed in textareas. Looks like I was wrong. I will try those tomorrow.
|Posted by Evilzebra, 01-06-2011, 03:31 PM|
|I was actually having this same issue, if the above solutions don't work below is what I did to solve the problem.
Add to Favourites Print this Article
Packages (Views: 287)