How to convert the text submitted by textarea to <p>

Source: Internet
Author: User
The carriage return of the text submitted by the form textarea is converted to the text submitted in the textarea of the & lt; p & gt; form. after the text is submitted, it is written to the mysql database, then read and display it. The result shows that the carriage return is missing. There are many sections, and the results are combined into a large segment. Is there any way to convert the carriage return of the text submitted by textarea in the form text


The text submitted in the form textarea is written to the mysql database and then read and displayed. The result shows that the carriage return is missing. There are many sections, and the results are combined into a large segment.

Is there any way to convert the carriage return submitted in the form textarea into an image?

What about this html tag? What is the conversion before writing data to the database? Or can it be converted after being read from the database?

Can you give me a specific code? Share To:] The text submitted in the form textarea is written to the mysql database after submission, and then read and displayed. The result shows that the carriage return is missing. There are many sections, and the results are combined into a large segment. Is there any way to put the tex... 'data-pics = ''>
------ Solution --------------------
Echo nl2br ($ arr [txt]);
------ Solution --------------------
$ Arr ['txt '] = nl2br ($ arr ['txt']);

Str_replace (char (13 )),"
", $ Arr [txt]);
Yes, because php does not have the char Function and only has the chr function.
However, it is inappropriate to write chr (13), because the linux text does not have this "carriage return" character, so if you write it yourself, you should write it.
$ Arr ['txt '] = preg_replace ("/[\ r \ n] + /","
", $ Arr ['txt ']);

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.