Home  >  Article  >  Backend Development  >  Replace the carriage return in textarea with _PHP tutorial

Replace the carriage return in textarea with _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:58:35881browse

Replace the carriage return in the textarea with

Today when I was writing a recruitment system, I found that the content submitted directly to the database was no longer in our original format. There were no line breaks, spaces, etc. in each line. After a detailed look, it turned out that we pressed Enter Spaces and spaces cannot be seen in the textarea, but they all have ascii codes. The asc code value of carriage return is 13 and the asc code value of space is 32. It is easy to know this. Let us give an example to illustrate:

$value =str_replace(chr(13),'
',$_POST['textvalue'])//This is to replace the carriage return in the textarea with a line feed, which can be done in html The normal display is the same as the format we have in textarea. Replacing spaces is str_replace(chr(32),'
',$_POST['textvalue'])//

It’s very simple.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631379.htmlTechArticleReplace the carriage return in textarea with br. Today when I was writing a recruitment system, I found that the content should be submitted directly to the database. Our original format is gone, all lines are broken in one line...
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