This article is an example of how PHP transforms text box content into HTML format. Share to everyone for your reference, specific as follows:
Sometimes we're going to use the HTML format for the content that you enter in a multiline text box to keep the original text formatting, such as wrapping, carriage return, and so on. You can do this by using the following function:
function shtm ($design _str)
{
$str =trim ($design _str);//get string at the same time to turn tail space and empty carriage return
//$str =str_replace ("<br > "," ", $str); Remove <br> label
//$str = "<p>". Trim ($STR);//Add <p>
$str =str_replace ("\ r \ n", "<br>") to the text header $STR); Replace line breaks
//$STR with P tags. = "</p>\n";//Text tail add </p>
$str =str_replace ("<p></p>", "", $str); /Remove empty paragraphs
$str =str_replace ("\ n", "", $str);//Remove blank lines and line
$str =str_replace ("</p>", "</p>\n", $str); /Organize HTML code return
$str;
}
PS: This site also provides the following conversion tools for everyone to choose to use:
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
HTML conversion to other language output tools:
Http://tools.jb51.net/code/HtmlCodeCov
For more information about PHP interested readers can view the site topics: "PHP coding and transcoding Operation tips Summary", "PHP object-oriented Programming Introduction Course", "PHP Mathematical Calculation Skills Summary", "PHP Array" Operation Techniques Encyclopedia, "PHP string (String) Usage summary, "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Regular Expression Usage Summary", and "PHP common database Operation skill Summary"
I hope this article will help you with the PHP program design.