Home  >  Article  >  php教程  >  把textarea里面的回车替换成

把textarea里面的回车替换成

WBOY
WBOYOriginal
2016-06-13 10:03:14972browse

把textarea里面的回车替换成

今天在写一个招聘系统时发现直接把内容提交到数据库以我们原有的格式己经没有了,所有的在一条第没有换行,空格等之类了,详细查看了一下原来我们回车与空格在textarea里面是看不到了,但是它们都有ascii代码,回车的asc是13 空间的asc码值是32,知道这个就简单了,我们举个例子来说明一下:

$value =str_replace(chr(13),'
',$_POST['textvalue'])//这里就是把textarea里面的回车替换成换行了,这要在html 里面就能正常的显示与我们在textarea里面的格式一样了,替换空格就是 str_replace(chr(32),'
',$_POST['textvalue'])//

很简单吧.

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