PHP converts the text box content to HTML format,

Source: Internet
Author: User

PHP converts the text box content to HTML format,

This document describes how to convert the text box content of PHP to HTML format. We will share this with you for your reference. The details are as follows:

Sometimes we will use to display the input content in multi-line text boxes in html format, so that we can maintain the original text format, such as line breaks and carriage returns. You can implement the following functions:

Function shtm ($ design_str) {$ str = trim ($ design_str); // get the string and remove both the leading and trailing spaces and the empty carriage return. // $ str = str_replace ("<br> ", "", $ str); // remove the <br> tag // $ str = "<p> ". trim ($ str); // Add <p> $ str = str_replace ("\ r \ n", "<br>", $ str) to the text header ); // Replace the linefeed with the p tag // $ str. = "</p> \ n"; // Add </p> $ str = str_replace ("<p> </p> ","", $ str); // remove an empty section $ str = str_replace ("\ n", "", $ str ); // Remove empty rows and join a row $ str = str_replace ("</p>", "</p> \ n", $ str ); // organize the html code return $ str ;}

PS: This site also provides the following conversion tools for your choice:

Online html/js/css code filtering tool:
Http://tools.jb51.net/code/htmlfilter

Online UBB/HTML code conversion tool:
Http://tools.jb51.net/transcoding/ubb2html

Tools for html conversion to output from other languages:
Http://tools.jb51.net/code/HtmlCodeCov

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.