This article describes the PHP using Str_replace to implement input box return to replace BR, share for everyone for reference. The implementation methods are as follows:
When we use textarea will find that carriage returns and spaces are not visible, so we use the Str_replace function to replace the \\n in PHP into BR can be, the need for friends can refer to the code as follows:
Copy Code code as follows:
function Htmtocode ($content) {
$content = Str_replace ("n", "<br>", Str_replace ("", "", $content));
return $content;
}
Replace the space first, and then substitute carriage return, equivalent to the following code:
Copy Code code as follows:
function Htmtocode ($content) {
$content = Str_replace ("", "", $content);
$content = Str_replace ("n", "<br>", $content);
return $content;
}
I hope this article will help you with your PHP program design.