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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-20 11:02:57
Original
1119 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...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template