教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php textarea提交到mysql中有很多空格

php textarea提交到mysql中有很多空格

发布时间:2018-09-18   编辑:jiaochengji.com
教程集为您提供php textarea提交到mysql中有很多空格等资源,欢迎您收藏本站,我们将为您提供最新的php textarea提交到mysql中有很多空格资源
有一些朋友可能会发现我们在html提交给php处理保存数据到mysql中之后会发现我们再次从mysql读出数据时会有很多的空格了,那么我们如果直接在mysql中查看又没有空间,这是什么问题要如何处理呢

textarea中总是有很多空格问题解决

问题描述:

在php读取mysql数据到textarea中开头可结尾总有很多空格,在数据表中查看数据是没有空格的。

问题原因:

内容应该顶着textarea写,textarea后不要有空格和换行

解决办法:

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2593')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2593>

<?php
echo str_replace(' ', '', 'ab    ab');
//输出 "abab'
?>

或者使用

<?php
echo strtr('ab    ab', array(' '=>''));
// 输出 "abab"
?>

补充:php textarea中的换行符为"\r\n"

不是'\n'

不是"<br />"

不是'\r\n'

不是'\r' '\n'

您可能感兴趣的文章:
php textarea提交到mysql中有很多空格
浅淡PHP生成HTML的思路
PHP防止重复提交表单的例子
MySQL常见错误代码解析
mysql索引优化提升数据库性能
JQuery textarea添加maxlength属性的例子
php表单提交特殊字符过滤方法
mysql怎么去除字段中换行符与回车符
分享:linux下mysql连接命令
各版本MySQL并行复制的实现及优缺点

[关闭]
~ ~