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

  • Home
  • SEARCH
  • 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 8677855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:34:13+00:00 2026-06-12T20:34:13+00:00

EDIT: My problem simplified I suppose has boiled down to not being able to

  • 0

EDIT:
My problem simplified I suppose has boiled down to not being able to completely remove the new line character.

I tried: $new_content = str_replace("\n", '<br/>', $_POST["new_content"]);
And I can’t see a reason why this wouldn’t work.. but when I inspect the text file I still have a mysterious new line like so:

event:|:Test:|:Line 1
<br/>Line 2:|:September 29th, 2012

Original question:

I have a form with a text field and a VERY simple ‘database’, that’s just a .txt file, that i am storing the submitted form data in. It all works well aside from one major issue i’ve just noticed. If a user presses the enter/return key to go to a new line in the text box, whatever the resultant string is it messes up my text file where a new line signifies another row in the database.

For examples here’s what the text file typically should look like:

type:|:heading:|:content:|:date
event:|:Big Event 2012:|:More info and booking details.:|:September 29th, 2012
event:|:Website relaunch:|:Keep your eyes pealed.:|:September 25th, 2012

Now if i were to fill out the form pressing the return key in the text box to start a new paragraph my text file looks like this:

type:|:heading:|:content:|:date
event:|:Test:|:paragraph 1
paragraph 2:|:September 29th, 2012
event:|:Website relaunch:|:Keep your eyes pealed.:|:September 25th, 2012

As you can see the string has resulted in a new row being used in the database whereas i would expect / desire something like..

event:|:Test:|:paragraph 1 \n paragraph 2 :|:September 29th, 2012 //or
event:|:Test:|:paragraph 1 <br/> paragraph 2 :|:September 29th, 2012

I did try looking for similar questions online but all the solutions pointed towards using something like nl2br($_POST["new_content"]); but that seems to produce a text file formatted like this:

type:|:heading:|:content:|:date
event:|:Test:|:paragraph 1<br />

paragraph 2:|:September 29th, 2012
event:|:Website relaunch:|:Keep your eyes pealed.:|:September 25th, 2012

Where the original problem still persists. Can someone explain why this happens or do you have any suggestions for how i should be formatting the string retrieved by $_POST["new_content"] before saving it in the text file? Would appreciate any help!

  • 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-12T20:34:14+00:00Added an answer on June 12, 2026 at 8:34 pm

    Answer found in the documentation comments for nl2br:

    strtr($text, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />'));
    

    Source: http://php.net/manual/en/function.nl2br.php#91828

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

Sidebar

Related Questions

Edit: This problem was down to me passing the wrong view to the Touch
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
EDIT: Simplified problem and clarified question. I am trying to convert this Stored Procedure
EDIT: I got some progress, so I have simplified and narrowed the problem: I
[EDIT: Problem solved. Please see my answer below.] In my app I call the
Ok, I'll put the code first hopefully to make it clearer. ***Edit: Problem is
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
Edit 1: Uninstalled & Reinstalled Edit 2: Same problem. Seriously? Yes. I am having
Most of you probably know the following problem: You edit an HTML, view the
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls

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.