Newline and PHP

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
calebrash
Forum Newbie
Posts: 1
Joined: Mon Nov 02, 2009 3:39 pm

Newline and PHP

Post by calebrash »

So I'm trying to account for newline characters and convert them to '<br />' before storing them in the db. However, my newlines are coming in as "%A" instead of '\r' or '\n', for some reason. Calling str_replace() fixes the problem except when the new line starts with 'A'. In that case, the leading 'A' is stored as a superscript 'a' and displays in HTML as a diamond with '?' in the middle (I guess it means some unknown character). I can't get rid of it with str_replace() because of character encoding, and nl2br() just takes care of regular newline characters.

Any help would be fantastic.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Newline and PHP

Post by Mark Baker »

have a look at urldecode(), see if that helps convert your %A correctly
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: Newline and PHP

Post by Mirge »

Post Reply