Textarea into an array or implode?

Posted by Kyle R on Stack Overflow See other posts from Stack Overflow or by Kyle R
Published on 2011-01-12T06:50:50Z Indexed on 2011/01/12 6:53 UTC
Read the original article Hit count: 168

Filed under:

Say I have a text area, user enters information exactly like styled below:

Ice cream
Chocolate

then submits this information, I want to retrieve the information EXACTLY like so:

Ice cream, Chocolate

Is this the best way to do it:

$arr = explode("\n", $var);
$arr = implode(",", $arr);

When doing it like this, it puts the information out like so:

Ice cream , Chocolate

Note the space after cream, will a simple trim() fix this?

© Stack Overflow or respective owner

Related posts about php