Problem with explode() and post data

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
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Problem with explode() and post data

Post by RandomEngy »

Hey, havn't been around in a few months with school and all, but I'm finally doing a bit more work on my database.

Anyway, I'm having some frustrating trouble dealing with some form data. Basically, I have a textarea on an input page, and I want the format to be:

Code: Select all

Item1
Item2
Item3
when they enter information. On the recieving end I do a

Code: Select all

$list_array=explode("\n",$_POSTї'stuff']);
to try to get all of the items. The problem is, each array string entry (except the last) has an extra \n at the end of it, which I've verified with a var_dump, and echoing each entry out. This doesn't happen when I manually enter a string like "Item1\nItem2\nItem3". I don't want those newlines there. I know I could always do a str_replace and get rid of them, but I'd really like to know what's going on.
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Excellent, I just have to explode with "\r\n" instead of just "\n" .
Post Reply