Php replaces textbox carriage return with html line feed code

Source: Internet
Author: User
The source of accepted news content is sometimes the text content in TextBox. However, if the text content is not processed, the text will not have any format, and will be displayed row by row.

The source of accepted news content is sometimes the text content in TextBox. However, if the text content is not processed, the text will not have any format, and will be displayed row by row. What we are talking about now is how to make text content line break without being crowded together.

During single-step debugging, we will find that in the obtained text content, the line feed in the text is replaced with "rn", because it has never been found, leading to a large circle. After finding this cause, you can replace this string with
.

String strBody = Body. Replace ("rn ","
");

Although it was easy, it was really a headache when I didn't know it at the time. I hope it will be useful to you too. The following are examples:

  1.  
  2. If ($ _ POST ){
  3. Echo str_replace (chr (13 ),'
    ', $ _ POST [' t']);
  4. }
  5. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.