Home >Backend Development >PHP Tutorial >Replace the carriage return in textarea with _PHP tutorial
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.