Jump to content

display the return as a return not as \r\n


jasonc

Recommended Posts

If a field is missed out when filling out a ofrm on my page they are taken back and told that they missed one out, the data they had already typed in is shown again.

 

but all the returns show as \r\n

 

how do I have it so the returns show as they were typed and not as the \r\n.

 

 

EDIT:

 

also how to i get the £ to show in my page as a £ and not as the diamond with a question mark.

 

Could we see the code that processes the form? Textareas are supposed to show linebreaks correctly, so what you are describing sounds rather weird. Regarding the £ sign, it seems to be a character encoding problem. What encoding are you using for your page?

when they type into an html text area the returns are sent as \n (most probably), but if you want to display them in html you have to convert them to

<br />

 

echo str_replace("\n","<br />",$string);

 

There's a built-in function for that: nl2br

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.