Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:13:50+00:00 2026-06-02T19:13:50+00:00

I am building an application where users can enter a note into a textarea.

  • 0

I am building an application where users can enter a note into a textarea. The note is then encoded when entered into the database. When I decode the returned value, the nl2br function isn’t working. It isn’t replacing the \r\n with the br tag. When not encoding/decoding text, it works.

I am using the following code to encode/decode my information: http://www.myphpscripts.net/tutorial.php?id=9

If I enter into a textarea:

Hello  
World

It encodes it, and then returns when decoded

Hello\r\nWorld.

I can do a str_replace, but as I come to understand, depending on the browser, a textarea may use \n or \r instead of \r\n.

Not sure what a good solution is… please help! Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:13:51+00:00Added an answer on June 2, 2026 at 7:13 pm

    If the text you are converting is in a “<textarea>” do not use “<br />”.

    If you are converting text to be placed in a text area, use…

    str_ireplace("\r\n", "\n", $db_string); //or something similar
    

    If you are converting text to be placed OUTSIDE a text area, use…

    str_ireplace(array("\r\n", "\n", "\r"), '<br />', $db_string);
    

    Separate browsers use whatever, but I believe they all can read just “\n”. However on a side note, the operating system determines “\r\n” vs “\n”. Just use “\n”. So replace “\r\n” with “\n”. Or just leave “\r\n”, use either, as long as you don’t put br tags into your textarea tags you’ll be all set.

    Mac = Linux = \n
    Windows = \r\n

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a web application where users can enter events, including event title
I am building an application where users can sign up and then challenge each
I am building a web application that uses the database for Users, Security/roles, and
I'm building an asp.net MVC application where users can attach a picture to their
I'm building an application where users can add, edit and delete users from the
I'm building an application where users can upload pictures. All I require is for
I am building an application that users can add, update data. Is there any
I am building a twitter application where a user can enter a tweet and
I am building an application that can have multiple users from multiple accounts. For
I am building an application where the users can download cooking recipes. Each recipe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.