Home > Backend Development > PHP Tutorial > php str_replace input box carriage return to replace br

php str_replace input box carriage return to replace br

高洛峰
Release: 2016-11-29 11:54:36
Original
1669 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:

function htmtocode ($content) {

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

return $content;

}

Replace it first Space, then replace the carriage return, which is equivalent to the following code:

function htmtocode($content) {

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

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

return $content;

//Open source code phpfensi.com

}


Related labels:
php
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