Home > Backend Development > PHP Tutorial > Convert br newline character in html to newline character in text input in php_PHP tutorial

Convert br newline character in html to newline character in text input in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:12:38
Original
789 people have browsed it

The following methods will help you solve this problem.

The PHP version converts the
line breaks in html to line breaks in the text box:

Copy code The code is as follows:

function br2nl($text){
return preg_replace('/
/i','',$text);
}

or:

Copy code The code is as follows:

function br2nl($text){
$text=preg_replace('/< ;br\s*?/??>/i',chr(13),$text);
return preg_replace('/ /i',' ',$text);
}

The JS version converts the
line breaks in html to line breaks in the text box:

Copy code The code is as follows:

function br2nl(txt){
var re=/(
|
|
|
)/g;
var s=txt.replace(re,"n");
return s;

http://www.bkjia.com/PHPjc/326703.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326703.htmlTechArticleThe following methods will help you solve this problem. PHP version converts br/line breaks in html to line breaks in text boxes: Copy code The code is as follows: function br2nl($text){ ret...
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
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