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.

 

Link to comment
Share on other sites

ah yes i have see that before, but how do i get the carriage return to be put back as they had originally typed in  like on this forum

 

if

I

put

returns

here they show again if i was to forget to fill out the title.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.