php textarea提交到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并行复制的实现及优缺点