<p>Inspection and treatment will be conducted to areas prone to Mouse infestation by our Service Specialist during the routine visits. This includes the sewerage system servicing the property.</p>
<p>Apart from treating the sewerage manhole, application of residual coat will also be done at strategic areas prone to Mouse activity/harborages, and when necessary, baits will be placed and application of gel will be carried out.</p>
<p>Preparations used are safe to humans and animals and is approved by the Ministry.</p>
上面是我要记录到mysql的文本,我想将它们修改为
<p>Inspection and treatment will be conducted to areas prone to Mouse infestation by our Service Specialist during the routine visits. This includes the sewerage system servicing the property.</p><p>Apart from treating the sewerage manhole, application of residual coat will also be done at strategic areas prone to Mouse activity/harborages, and when necessary, baits will be placed and application of gel will be carried out.</p><p>Preparations used are safe to humans and animals and is approved by the Ministry.</p>
我使用了以下代码:
$service_desc = preg_replace('/\s+/', ' ', $service_desc);
但是代码没有解决字符串文本之间的间距,我怎样才能删除其间的空格来实现我想要的结果。
谢谢!
答案 0 :(得分:0)
如果你想删除de end of line字符,这不是更容易吗?
$service_desc = str_replace("\r\n", '', $service_desc);
或
$service_desc = str_replace("\n", '', $service_desc);
很抱歉,如果这不是您的要求。
答案 1 :(得分:0)
您可以使用FetchType.EAGER
并将CSS
设置为0来解决此问题:
margin
<style type="text/css">
p { margin:0 }
</style>
p { margin:0 }
答案 2 :(得分:0)
如果要删除标签之间的空格,请使用
$text = preg_replace('/>\s+</', '><', $text);
这也会删除内联标记之间的空格,例如两个相邻的<span>
元素,这可能不是您想要的。