Home  >  Article  >  Backend Development  >  php str_replace input box carriage return replacement br_PHP tutorial

php str_replace input box carriage return replacement br_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:571071browse

When we use textarea, we will find that carriage returns and spaces are not visible, so we use the str_replace function to replace n in php with br. Friends in need can refer to it. ​

The code is as follows Copy code
 代码如下 复制代码

function htmtocode($content) {
    $content = str_replace("n", "
", str_replace(" ", " ", $content));
    return $content;
}

function htmtocode($content) {

$content = str_replace("n", "
", str_replace(" ", " ", $content));
Return $content;

}
 代码如下 复制代码
function htmtocode($content) {
    $content = str_replace(" ", " ", $content);
    $content = str_replace("n", "
",$content);  
    return $content;
}

Replace the spaces first, then the carriage returns.

Equivalent to:

The code is as follows Copy code
function htmtocode($content) { $content = str_replace("n", " ",$content); Return $content; }
http://www.bkjia.com/PHPjc/445331.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/445331.html
TechArticleWhen we use textarea, we will find that carriage returns and spaces are not visible, so we use the str_replace function to replace php Just replace n with br. Friends in need can refer to it. Generation...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn