开发者

How to rid of extra white space?

开发者 https://www.devze.com 2023-03-03 20:27 出处:网络
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 t

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')

0

精彩评论

暂无评论...
验证码 换一张
取 消