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

php str_replace input box carriage return replacement br_PHP tutorial

WBOY
Release: 2016-07-20 11:02:57
Original
1090 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template