How to rid of extra white space?
I have a textbox that i use nl2br to insert into db. The problem is that 开发者_运维问答
is adding too much space. Is there a way to assign this an id while being processed or some other way to reduce the space between sentences?Looks like what you want is some cleanups of those lines. This is what I use on my php apps.
<?php
function trimlines($html){
$ret = str_replace("\r\n","\n",$html);
$ret = explode("\n",$ret);
$ret = array_map('trim',$ret);
$ret = join("\r\n",$ret);
return $ret;
}
?>
Regular expressions can also be used, but for quick cleanups, this works well for me. Hope it helps :)
I would suggest wrapping the variable in sql with TRIM('sentences here')
精彩评论